Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Stores all Conn types by their uuid. ConnManager = struct { sync.Mutex Conns map[string]*Conn }{ Conns: make(map[string]*Conn), } // Emits received Messages with non-reserved event names. Emitter = emission.NewEmitter() )
View Source
var RoomManager = struct { sync.Mutex Rooms map[string]*Room }{ Rooms: make(map[string]*Room, 0), }
Stores all Room types by their name.
Functions ¶
func SocketHandler ¶
func SocketHandler(cr CookieReader) http.HandlerFunc
Calls NewConnection, starts the returned Conn's writer, joins the root room, and finally starts the Conn's reader.
Types ¶
type Conn ¶
type Conn struct { sync.Mutex Cookie map[string]string Socket *websocket.Conn ID string Send chan []byte Rooms map[string]string }
The Conn type represents a single client.
func NewConnection ¶
func NewConnection(w http.ResponseWriter, r *http.Request, cr CookieReader) *Conn
Upgrades an HTTP connection and creates a new Conn type.
type Message ¶
type Message struct { RoomLength int // room name length Room string // room name EventLength int // event name length Event string // event name DstLength int // destination id length Dst string // destination id SrcLength int // source id length Src string // source id PayloadLength int // payload length Payload []byte // payload }
Message protocol followed by wsrooms servers and clients.
func ConstructMessage ¶
Constructs and returns a new Message type.
type Room ¶
type Room struct { sync.Mutex Name string Members map[string]string Send chan *RoomMessage // contains filtered or unexported fields }
The Room type represents a communication channel.
type RoomMessage ¶
Message protocol used only with a room's Send channel.
Click to show internal directories.
Click to hide internal directories.