Skip to content

Instantly share code, notes, and snippets.

@domino14
Created July 22, 2020 04:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save domino14/ef57e613ceeff2fcd5a9d9a1e11814dd to your computer and use it in GitHub Desktop.
Save domino14/ef57e613ceeff2fcd5a9d9a1e11814dd to your computer and use it in GitHub Desktop.
Websocket hub for liwords
type Realm string
type Hub struct {
// Registered clients.
clients map[*Client]Realm
clientsByUserID map[string]map[*Client]bool
register chan *Client
unregister chan *Client
pubsub *PubSub
realmMutex sync.Mutex
// Each realm has a list of clients in it.
realms map[Realm]map[*Client]bool
broadcastRealm chan RealmMessage
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment