Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Epher ¶
Epher is the main struct to store the global state
func (*Epher) PushHandler ¶
func (e *Epher) PushHandler(rw http.ResponseWriter, r *http.Request)
PushHandler sends the HTTP post to the websocket listeners
func (*Epher) WebsocketHandler ¶
func (e *Epher) WebsocketHandler(rw http.ResponseWriter, r *http.Request)
WebsocketHandler is the public websocket interface For every new websocket connection we'll keep a new handler open
type Room ¶
Room is the global state for each room
func (*Room) BroadcastText ¶
BroadcastText broadcast a text message in the room
type Roomer ¶
type Roomer interface { AddUser(u *User) DelUser(u *User) UserCount() int BroadcastText(b []byte) error Stop() }
Roomer help testing the room related here
type TextSender ¶
TextBroadcaster helps mocking the SendText call This is an alternate solution to the Roomer (in the handler.go) which define how a Room should work. Here we just define a single requirement to have the User struct a specific method and tie it to an interface. Now in the room_test.go we could simply overwrite how this function should work
type User ¶
type User struct { ID int64 TextSender // Embed the interface // contains filtered or unexported fields }
User handler to wrap read/write and other data