Documentation ¶
Index ¶
- type Broadcast
- type Conn
- type EachFunc
- type Namespace
- type RedisAdapterOptions
- type Server
- func (s *Server) Adapter(opts *RedisAdapterOptions) (bool, error)
- func (s *Server) BroadcastToNamespace(namespace string, event string, args ...interface{}) bool
- func (s *Server) BroadcastToRoom(namespace string, room, event string, args ...interface{}) bool
- func (s *Server) ClearRoom(namespace string, room string) bool
- func (s *Server) Close() error
- func (s *Server) Count() int
- func (s *Server) ForEach(namespace string, room string, f EachFunc) bool
- func (s *Server) JoinRoom(namespace string, room string, connection Conn) bool
- func (s *Server) LeaveAllRooms(namespace string, connection Conn) bool
- func (s *Server) LeaveRoom(namespace string, room string, connection Conn) bool
- func (s *Server) OnConnect(namespace string, f func(Conn) error)
- func (s *Server) OnDisconnect(namespace string, f func(Conn, string))
- func (s *Server) OnError(namespace string, f func(Conn, error))
- func (s *Server) OnEvent(namespace, event string, f interface{})
- func (s *Server) RoomLen(namespace string, room string) int
- func (s *Server) Rooms(namespace string) []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 ¶ added in v1.4.2
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 ForEach(room string, f EachFunc) // ForEach sends data by DataFunc, if room does not exits sends nothing 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 AllRooms() []string // Gives list of all the rooms the connection joined }
Broadcast is the adaptor to handle broadcasts & rooms for socket.io server API
type Conn ¶ added in v1.4.1
type Conn interface { io.Closer Namespace // ID returns session id ID() string URL() url.URL LocalAddr() net.Addr RemoteAddr() net.Addr RemoteHeader() http.Header }
Conn is a connection in go-socket.io
type Namespace ¶ added in v1.0.1
type Namespace interface { // 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(ctx interface{}) Namespace() string Emit(eventName string, v ...interface{}) Join(room string) Leave(room string) LeaveAll() Rooms() []string }
Namespace describes a communication channel that allows you to split the logic of your application over a single shared connection.
type RedisAdapterOptions ¶ added in v1.4.5
RedisAdapterOptions is configuration to create new adapter
type Server ¶ added in v1.0.1
type Server struct {
// contains filtered or unexported fields
}
Server is a go-socket.io server.
func (*Server) Adapter ¶ added in v1.4.5
func (s *Server) Adapter(opts *RedisAdapterOptions) (bool, error)
Adapter sets redis broadcast adapter.
func (*Server) BroadcastToNamespace ¶ added in v1.4.5
BroadcastToNamespace broadcasts given event & args to all the connections in the same namespace.
func (*Server) BroadcastToRoom ¶ added in v1.4.2
BroadcastToRoom broadcasts given event & args to all the connections in the room.
func (*Server) ForEach ¶ added in v1.4.3
ForEach sends data by DataFunc, if room does not exits sends nothing.
func (*Server) LeaveAllRooms ¶ added in v1.4.2
LeaveAllRooms leaves the given connection from all rooms.
func (*Server) OnConnect ¶ added in v1.4.1
OnConnect set a handler function f to handle open event for namespace.
func (*Server) OnDisconnect ¶ added in v1.4.1
OnDisconnect set a handler function f to handle disconnect event for namespace.
func (*Server) OnError ¶ added in v1.4.1
OnError set a handler function f to handle error for namespace.
func (*Server) OnEvent ¶ added in v1.4.1
OnEvent set a handler function f to handle event for namespace.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
_examples
|
|
gf
Module
|
|
gin-cors
Module
|
|
gin-gonic
Module
|
|
go-echo
Module
|
|
graceful-shutdown
Module
|
|
iris
Module
|
|
pprof
Module
|
|
redis-adapter
Module
|
|
example
|
|
iris
Module
|
|