Documentation ¶
Index ¶
- type Broadcast
- type Conn
- type Server
- func (s *Server) BroadcastToRoom(room, event string, args ...interface{})
- func (s *Server) ClearRoom(room string)
- func (s *Server) Close() error
- func (s *Server) JoinRoom(room string, connection Conn)
- func (s *Server) LeaveAllRooms(connection Conn)
- func (s *Server) LeaveRoom(room string, connection Conn)
- func (s *Server) OnConnect(nsp string, f func(Conn) error)
- func (s *Server) OnDisconnect(nsp string, f func(Conn, string))
- func (s *Server) OnError(nsp string, f func(Conn, error))
- func (s *Server) OnEvent(nsp, event string, f interface{})
- func (s *Server) RoomLen(room string) int
- func (s *Server) Rooms() []string
- func (s *Server) Serve() error
- func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Broadcast ¶
type Broadcast interface { Join(room string, connection Conn) // Join causes the connection to join a room Leave(room string, connection Conn) // Leave causes the connection to leave a room LeaveAll(connection Conn) // LeaveAll causes given connection to leave all rooms Clear(room string) // Clear causes removal of all connections from the room Send(room, event string, args ...interface{}) // Send will send an event with args to the room SendAll(event string, args ...interface{}) // SendAll will send an event with args to all the rooms Len(room string) int // Len gives number of connections in the room Rooms(connection Conn) []string // Gives list of all the rooms if no connection given, else list of all the rooms the connection joined }
Broadcast is the adaptor to handle broadcasts & rooms for socket.io server API
type Conn ¶
type Conn interface { // ID returns session id ID() string Close() error URL() url.URL LocalAddr() net.Addr RemoteAddr() net.Addr RemoteHeader() http.Header // Context of this connection. You can save one context for one // connection, and share it between all handlers. The handlers // is called in one goroutine, so no need to lock context if it // only be accessed in one connection. Context() interface{} SetContext(v interface{}) Namespace() string Emit(msg string, v ...interface{}) // Broadcast server side apis Join(room string) Leave(room string) LeaveAll() Rooms() []string }
Conn is a connection in go-socket.io
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a go-socket.io server.
func (*Server) BroadcastToRoom ¶
BroadcastToRoom broadcasts given event & args to all the connections in the room
func (*Server) LeaveAllRooms ¶
LeaveAllRooms leaves the given connection from all rooms
func (*Server) OnConnect ¶
OnConnect set a handler function f to handle open event for namespace nsp.
func (*Server) OnDisconnect ¶
OnDisconnect set a handler function f to handle disconnect event for namespace nsp.
Click to show internal directories.
Click to hide internal directories.