Module buddyshopping

WebSocket server for BuddyShopping Ecwid app.

Types

Customer = object
  id: string
  name: string
  ws: AsyncWebSocket
  isHost: bool
  isReadyToCheckout: bool
Cart = object
  owner: Customer
  content: JsonNode
Session = Table[string, Cart]
State = Table[string, Session]

Procs

proc initCustomer(name: string; ws: AsyncWebSocket; isHost = false): Customer {...}{.
    raises: [], tags: [].}
Create a Customer instance. id is an oid.
proc broadcast(session: Session; message: string): Future[void] {...}{.
    raises: [FutureError], tags: [RootEffect, WriteIOEffect, ReadIOEffect].}
Send message to all customers in session.
proc cleanup(state: var State) {...}{.raises: [], tags: [].}
Remove disconnected websockets from sessions and empty sessions from the state.

Funcs

func initCart(owner: Customer): Cart {...}{.raises: [], tags: [].}
Create a Cart instance with the given owner. Default content is an empty JSON object.
func initSession(): Session {...}{.raises: [], tags: [].}
Create a session as an empty table of strings to Carts.
func initState(): State {...}{.raises: [], tags: [].}
Create a state as an empty table of strings to Sessions.
func multicart(session: Session): JsonNode {...}{.raises: [], tags: [].}
Generate multicart, which is an entire session's state in JSON form.