Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn interface { ID() string Close() error URL() *url.URL RemoteAddr() string RemoteHeader() http.Header Context() interface{} SetContext(v interface{}) Emit(ctx context.Context, event string, body []byte) error EmitWithAck(ctx context.Context, event string, body []byte) ([]byte, error) Closed() bool }
type RoomStore ¶
type RoomStore interface { Add(Conn) Remove(Conn) Get(connId string) (Conn, bool) Join(conn Conn, rooms ...string) Leave(conn Conn, rooms ...string) LeaveByConnId(id string, rooms ...string) Len(room string) int Clear(rooms ...string) Rooms() []string ToBroadcast(rooms ...string) []Conn }
func NewRoomStore ¶
func NewRoomStore() RoomStore
type Server ¶
type Server interface { Close() ServeHttp(w http.ResponseWriter, r *http.Request) OnWithAck(event string, f func(conn Conn, data []byte) []byte) Server // If registered, all unknown events will be handled here. OnDefault(f func(event string, conn Conn, data []byte)) Server On(event string, f func(conn Conn, data []byte)) Server Unsubscribe(event string) Server OnConnect(f func(Conn)) Server OnDisconnect(f func(Conn, error)) Server // Conn may be nil if error occurs on connection upgrade or in RequestHandler. OnError(f func(Conn, error)) Server Rooms() RoomStore BroadcastToRoom(room string, event string, data []byte) error BroadcastToAll(event string, data []byte) error }
type ServerConfig ¶
type ServerConfig struct { // Can be used to define custom CORS policy. RequestHandler func(*http.Request) error // By default, the connection has a message read limit of 32768 bytes. // When the limit is hit, the connection will be closed with StatusMessageTooBig. ConnectionReadLimit int64 // Checks origin header to prevent CSRF attack. InsecureSkipVerify bool }
Click to show internal directories.
Click to hide internal directories.