go-socket.io: github.com/googollee/go-socket.io Index | Files | Directories

package socketio

import "github.com/googollee/go-socket.io"

Index

Package Files

broadcast.go conn.go errors.go handler.go namespace_conn.go namespace_handler.go server.go types.go

type Broadcast Uses

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 Uses

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 EachFunc Uses

type EachFunc func(Conn)

EachFunc typed for each callback function

type Namespace Uses

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.
    SetContext(ctx interface{})
    Context() interface{}
    Namespace() string
    Emit(eventName string, v ...interface{})

    // Broadcast server side apis
    Join(room string)
    Leave(room string)
    LeaveAll()
    Rooms() []string
}

Namespace

type Server Uses

type Server struct {
    // contains filtered or unexported fields
}

Server is a go-socket.io server.

func NewServer Uses

func NewServer(c *engineio.Options) *Server

NewServer returns a server.

func (*Server) BroadcastToRoom Uses

func (s *Server) BroadcastToRoom(namespace string, room, event string, args ...interface{}) bool

BroadcastToRoom broadcasts given event & args to all the connections in the room

func (*Server) ClearRoom Uses

func (s *Server) ClearRoom(namespace string, room string) bool

ClearRoom clears the room

func (*Server) Close Uses

func (s *Server) Close() error

Close closes server.

func (*Server) Count Uses

func (s *Server) Count() int

Count number of connections

func (*Server) ForEach Uses

func (s *Server) ForEach(namespace string, room string, f EachFunc) bool

ForEach sends data by DataFunc, if room does not exits sends nothing

func (*Server) JoinRoom Uses

func (s *Server) JoinRoom(namespace string, room string, connection Conn) bool

JoinRoom joins given connection to the room

func (*Server) LeaveAllRooms Uses

func (s *Server) LeaveAllRooms(namespace string, connection Conn) bool

LeaveAllRooms leaves the given connection from all rooms

func (*Server) LeaveRoom Uses

func (s *Server) LeaveRoom(namespace string, room string, connection Conn) bool

LeaveRoom leaves given connection from the room

func (*Server) OnConnect Uses

func (s *Server) OnConnect(namespace string, f func(Conn) error)

OnConnect set a handler function f to handle open event for namespace nsp.

func (*Server) OnDisconnect Uses

func (s *Server) OnDisconnect(nsp string, f func(Conn, string))

OnDisconnect set a handler function f to handle disconnect event for namespace nsp.

func (*Server) OnError Uses

func (s *Server) OnError(namespace string, f func(Conn, error))

OnError set a handler function f to handle error for namespace.

func (*Server) OnEvent Uses

func (s *Server) OnEvent(namespace, event string, f interface{})

OnEvent set a handler function f to handle event for namespace.

func (*Server) RoomLen Uses

func (s *Server) RoomLen(namespace string, room string) int

RoomLen gives number of connections in the room

func (*Server) Rooms Uses

func (s *Server) Rooms(namespace string) []string

Rooms gives list of all the rooms

func (*Server) Serve Uses

func (s *Server) Serve() error

Serve serves go-socket.io server

func (*Server) ServeHTTP Uses

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

Directories

PathSynopsis
engineio
engineio/base
engineio/packetPackage packet is codec of packet for connection which supports framing.
engineio/payload
engineio/transport
engineio/transport/polling
engineio/transport/websocket
parser

Package socketio imports 10 packages (graph) and is imported by 208 packages. Updated 2020-10-13. Refresh now. Tools for package owners.