Documentation ¶
Index ¶
Constants ¶
View Source
const ( // All is the string which the Emmiter use to send a message to all All = "" // NotMe is the string which the Emmiter use to send a message to all except this connection NotMe = ";iris;to;all;except;me;" // Broadcast is the string which the Emmiter use to send a message to all except this connection, same as 'NotMe' Broadcast = NotMe )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection interface { // Emmiter implements EmitMessage & Emit Emmiter // ID returns the connection's identifier ID() string // OnDisconnect registers a callback which fires when this connection is closed by an error or manual OnDisconnect(DisconnectFunc) // To defines where server should send a message // returns an emmiter to send messages To(string) Emmiter // OnMessage registers a callback which fires when native websocket message received OnMessage(NativeMessageFunc) // On registers a callback to a particular event which fires when a message to this event received On(string, MessageFunc) // Join join a connection to a room, it doesn't check if connection is already there, so care Join(string) // Leave removes a connection from a room Leave(string) }
Connection is the client
type ConnectionFunc ¶
type ConnectionFunc func(Connection)
ConnectionFunc is the callback which fires when a client/connection is connected to the server. Receives one parameter which is the Connection
type DisconnectFunc ¶
type DisconnectFunc func()
DisconnectFunc is the callback which fires when a client/connection closed
type Emmiter ¶
type Emmiter interface { // EmitMessage sends a native websocket message EmitMessage([]byte) error // Emit sends a message on a particular event Emit(string, interface{}) error }
Emmiter is the message/or/event manager
type MessageFunc ¶
type MessageFunc interface{}
MessageFunc is the second argument to the Emitter's Emit functions. A callback which should receives one parameter of type string, int, bool or any valid JSON/Go struct
type NativeMessageFunc ¶
type NativeMessageFunc func([]byte)
NativeMessageFunc is the callback for native websocket messages, receives one []byte parameter which is the raw client's message
type Server ¶
type Server interface { // Upgrade upgrades the client in order websocket works Upgrade(context.IContext) error // OnConnection registers a callback which fires when a connection/client is connected to the server OnConnection(ConnectionFunc) }
Server is the websocket server
Click to show internal directories.
Click to hide internal directories.