Versions in this module Expand all Collapse all v2 v2.0.6 Feb 29, 2024 Changes in this version + var NAMESPACE_RESERVED_EVENTS = types.NewSet("connect", "connection", "new_namespace") + var RECOVERABLE_DISCONNECT_REASONS = types.NewSet("transport error", "transport close", "forced close", "ping timeout", ...) + var SOCKET_RESERVED_EVENTS = types.NewSet("connect", "connect_error", "disconnect", "disconnecting", "newListener", ...) + type Adapter interface + AddAll func(SocketId, *types.Set[Room]) + AddSockets func(*BroadcastOptions, []Room) + Broadcast func(*parser.Packet, *BroadcastOptions) + BroadcastWithAck func(*parser.Packet, *BroadcastOptions, func(uint64), func([]any, error)) + Close func() + Construct func(NamespaceInterface) + Del func(SocketId, Room) + DelAll func(SocketId) + DelSockets func(*BroadcastOptions, []Room) + DisconnectSockets func(*BroadcastOptions, bool) + FetchSockets func(*BroadcastOptions) func(func([]SocketDetails, error)) + Init func() + Nsp func() NamespaceInterface + PersistSession func(*SessionToPersist) + Proto func() Adapter + Prototype func(Adapter) + RestoreSession func(PrivateSessionId, string) (*Session, error) + Rooms func() *types.Map[Room, *types.Set[SocketId]] + ServerCount func() int64 + ServerSideEmit func([]any) error + Sids func() *types.Map[SocketId, *types.Set[Room]] + SocketRooms func(SocketId) *types.Set[Room] + Sockets func(*types.Set[Room]) *types.Set[SocketId] + func MakeAdapter() Adapter + func MakeSessionAwareAdapter() Adapter + func NewAdapterNew(nsp NamespaceInterface) Adapter + func NewSessionAwareAdapter(nsp NamespaceInterface) Adapter + type AdapterBuilder struct + func (*AdapterBuilder) New(nsp NamespaceInterface) Adapter + type AdapterConstructor interface + New func(NamespaceInterface) Adapter + type BroadcastAdapter func(*parser.Packet, *BroadcastOptions) + func (BroadcastAdapter) AddAll(SocketId, *types.Set[Room]) + func (BroadcastAdapter) AddListener(events.EventName, ...events.Listener) error + func (BroadcastAdapter) AddSockets(*BroadcastOptions, []Room) + func (BroadcastAdapter) BroadcastWithAck(*parser.Packet, *BroadcastOptions, func(uint64), func([]any, error)) + func (BroadcastAdapter) Clear() + func (BroadcastAdapter) Close() + func (BroadcastAdapter) Construct(NamespaceInterface) + func (BroadcastAdapter) Del(SocketId, Room) + func (BroadcastAdapter) DelAll(SocketId) + func (BroadcastAdapter) DelSockets(*BroadcastOptions, []Room) + func (BroadcastAdapter) DisconnectSockets(*BroadcastOptions, bool) + func (BroadcastAdapter) Emit(events.EventName, ...any) + func (BroadcastAdapter) EventNames() []events.EventName + func (BroadcastAdapter) FetchSockets(*BroadcastOptions) func(func([]SocketDetails, error)) + func (BroadcastAdapter) GetMaxListeners() uint + func (BroadcastAdapter) Init() + func (BroadcastAdapter) Len() int + func (BroadcastAdapter) ListenerCount(events.EventName) int + func (BroadcastAdapter) Listeners(events.EventName) []events.Listener + func (BroadcastAdapter) Nsp() NamespaceInterface + func (BroadcastAdapter) On(events.EventName, ...events.Listener) error + func (BroadcastAdapter) Once(events.EventName, ...events.Listener) error + func (BroadcastAdapter) PersistSession(*SessionToPersist) + func (BroadcastAdapter) Prototype(Adapter) + func (BroadcastAdapter) RemoveAllListeners(events.EventName) bool + func (BroadcastAdapter) RemoveListener(events.EventName, events.Listener) bool + func (BroadcastAdapter) RestoreSession(PrivateSessionId, string) (*Session, error) + func (BroadcastAdapter) Rooms() *types.Map[Room, *types.Set[SocketId]] + func (BroadcastAdapter) ServerCount() int64 + func (BroadcastAdapter) ServerSideEmit([]any) error + func (BroadcastAdapter) SetMaxListeners(uint) + func (BroadcastAdapter) Sids() *types.Map[SocketId, *types.Set[Room]] + func (BroadcastAdapter) SocketRooms(SocketId) *types.Set[Room] + func (BroadcastAdapter) Sockets(*types.Set[Room]) *types.Set[SocketId] + func (ba BroadcastAdapter) Broadcast(packet *parser.Packet, opts *BroadcastOptions) + func (ba BroadcastAdapter) Proto() Adapter + type BroadcastFlags struct + Binary bool + Broadcast bool + ExpectSingleResponse bool + Local bool + Timeout *time.Duration + type BroadcastOperator struct + func MakeBroadcastOperator() *BroadcastOperator + func NewBroadcastOperator(adapter Adapter, rooms *types.Set[Room], exceptRooms *types.Set[Room], ...) *BroadcastOperator + func (b *BroadcastOperator) AllSockets() (*types.Set[SocketId], error) + func (b *BroadcastOperator) Compress(compress bool) *BroadcastOperator + func (b *BroadcastOperator) Construct(adapter Adapter, rooms *types.Set[Room], exceptRooms *types.Set[Room], ...) + func (b *BroadcastOperator) DisconnectSockets(status bool) + func (b *BroadcastOperator) Emit(ev string, args ...any) error + func (b *BroadcastOperator) EmitWithAck(ev string, args ...any) func(func([]any, error)) + func (b *BroadcastOperator) Except(room ...Room) *BroadcastOperator + func (b *BroadcastOperator) FetchSockets() func(func([]*RemoteSocket, error)) + func (b *BroadcastOperator) In(room ...Room) *BroadcastOperator + func (b *BroadcastOperator) Local() *BroadcastOperator + func (b *BroadcastOperator) SocketsJoin(room ...Room) + func (b *BroadcastOperator) SocketsLeave(room ...Room) + func (b *BroadcastOperator) Timeout(timeout time.Duration) *BroadcastOperator + func (b *BroadcastOperator) To(room ...Room) *BroadcastOperator + func (b *BroadcastOperator) Volatile() *BroadcastOperator + type BroadcastOptions struct + Except *types.Set[Room] + Flags *BroadcastFlags + Rooms *types.Set[Room] + type Client struct + func MakeClient() *Client + func NewClient(server *Server, conn engine.Socket) *Client + func (c *Client) Conn() engine.Socket + func (c *Client) Construct(server *Server, conn engine.Socket) + func (c *Client) Request() *types.HttpContext + func (c *Client) WriteToEngine(encodedPackets []_types.BufferInterface, opts *WriteOptions) + type ConnectionStateRecovery struct + func (c *ConnectionStateRecovery) GetRawMaxDisconnectionDuration() *int64 + func (c *ConnectionStateRecovery) GetRawSkipMiddlewares() *bool + func (c *ConnectionStateRecovery) MaxDisconnectionDuration() int64 + func (c *ConnectionStateRecovery) SetMaxDisconnectionDuration(maxDisconnectionDuration int64) + func (c *ConnectionStateRecovery) SetSkipMiddlewares(skipMiddlewares bool) + func (c *ConnectionStateRecovery) SkipMiddlewares() bool + type ExtendedError struct + func NewExtendedError(message string, data any) *ExtendedError + func (e *ExtendedError) Data() any + func (e *ExtendedError) Err() error + func (e *ExtendedError) Error() string + type Handshake struct + Address string + Auth any + Headers map[string][]string + Issued int64 + Query map[string][]string + Secure bool + Time string + Url string + Xdomain bool + type Namespace struct + func MakeNamespace() *Namespace + func NewNamespace(server *Server, name string) *Namespace + func (n *Namespace) Adapter() Adapter + func (n *Namespace) Add(client *Client, auth any, fn func(*Socket)) + func (n *Namespace) AllSockets() (*types.Set[SocketId], error) + func (n *Namespace) Compress(compress bool) *BroadcastOperator + func (n *Namespace) Construct(server *Server, name string) + func (n *Namespace) DisconnectSockets(status bool) + func (n *Namespace) Emit(ev string, args ...any) error + func (n *Namespace) EmitWithAck(ev string, args ...any) func(func([]any, error)) + func (n *Namespace) EventEmitter() *StrictEventEmitter + func (n *Namespace) Except(room ...Room) *BroadcastOperator + func (n *Namespace) FetchSockets() func(func([]*RemoteSocket, error)) + func (n *Namespace) Ids() uint64 + func (n *Namespace) In(room ...Room) *BroadcastOperator + func (n *Namespace) InitAdapter() + func (n *Namespace) Local() *BroadcastOperator + func (n *Namespace) Name() string + func (n *Namespace) OnServerSideEmit(ev string, args ...any) + func (n *Namespace) Proto() NamespaceInterface + func (n *Namespace) Prototype(_n NamespaceInterface) + func (n *Namespace) Send(args ...any) NamespaceInterface + func (n *Namespace) Server() *Server + func (n *Namespace) ServerSideEmit(ev string, args ...any) error + func (n *Namespace) ServerSideEmitWithAck(ev string, args ...any) func(func([]any, error)) + func (n *Namespace) Sockets() *types.Map[SocketId, *Socket] + func (n *Namespace) SocketsJoin(room ...Room) + func (n *Namespace) SocketsLeave(room ...Room) + func (n *Namespace) Timeout(timeout time.Duration) *BroadcastOperator + func (n *Namespace) To(room ...Room) *BroadcastOperator + func (n *Namespace) Use(fn func(*Socket, func(*ExtendedError))) NamespaceInterface + func (n *Namespace) Volatile() *BroadcastOperator + func (n *Namespace) Write(args ...any) NamespaceInterface + type NamespaceInterface interface + Adapter func() Adapter + Add func(*Client, any, func(*Socket)) + AllSockets func() (*types.Set[SocketId], error) + Compress func(bool) *BroadcastOperator + Construct func(*Server, string) + DisconnectSockets func(bool) + Emit func(string, ...any) error + EmitReserved func(string, ...any) + EmitUntyped func(string, ...any) + EmitWithAck func(string, ...any) func(func([]any, error)) + EventEmitter func() *StrictEventEmitter + Except func(...Room) *BroadcastOperator + FetchSockets func() func(func([]*RemoteSocket, error)) + Ids func() uint64 + In func(...Room) *BroadcastOperator + InitAdapter func() + Listeners func(string) []events.Listener + Local func() *BroadcastOperator + Name func() string + On func(string, ...events.Listener) error + OnServerSideEmit func(string, ...any) + Once func(string, ...events.Listener) error + Proto func() NamespaceInterface + Prototype func(NamespaceInterface) + Send func(...any) NamespaceInterface + Server func() *Server + ServerSideEmit func(string, ...any) error + ServerSideEmitWithAck func(string, ...any) func(func([]any, error)) + Sockets func() *types.Map[SocketId, *Socket] + SocketsJoin func(...Room) + SocketsLeave func(...Room) + Timeout func(time.Duration) *BroadcastOperator + To func(...Room) *BroadcastOperator + Use func(func(*Socket, func(*ExtendedError))) NamespaceInterface + Volatile func() *BroadcastOperator + Write func(...any) NamespaceInterface + type ParentNamespace struct + func MakeParentNamespace() *ParentNamespace + func NewParentNamespace(server *Server) *ParentNamespace + func (p *ParentNamespace) CreateChild(name string) *Namespace + func (p *ParentNamespace) Emit(ev string, args ...any) error + func (p *ParentNamespace) FetchSockets() func(func([]*RemoteSocket, error)) + func (p *ParentNamespace) InitAdapter() + type ParentNspNameMatchFn *func(string, any, func(error, bool)) + type PersistedPacket struct + Data any + EmittedAt int64 + Id string + Opts *BroadcastOptions + type PrivateSessionId string + type RemoteSocket struct + func MakeRemoteSocket() *RemoteSocket + func NewRemoteSocket(adapter Adapter, details SocketDetails) *RemoteSocket + func (r *RemoteSocket) Construct(adapter Adapter, details SocketDetails) + func (r *RemoteSocket) Data() any + func (r *RemoteSocket) Disconnect(status bool) *RemoteSocket + func (r *RemoteSocket) Emit(ev string, args ...any) error + func (r *RemoteSocket) Handshake() *Handshake + func (r *RemoteSocket) Id() SocketId + func (r *RemoteSocket) Join(room ...Room) + func (r *RemoteSocket) Leave(room ...Room) + func (r *RemoteSocket) Rooms() *types.Set[Room] + func (r *RemoteSocket) Timeout(timeout time.Duration) *BroadcastOperator + type Room string + type SeesionData struct + Offset any + Pid any + func (s *SeesionData) GetOffset() (offset string, ok bool) + func (s *SeesionData) GetPid() (pid string, ok bool) + type Server struct + func MakeServer() *Server + func NewServer(srv any, opts *ServerOptions) *Server + func (s *Server) Adapter() AdapterConstructor + func (s *Server) AllSockets() (*types.Set[SocketId], error) + func (s *Server) Attach(srv any, opts *ServerOptions) *Server + func (s *Server) Bind(egs engine.BaseServer) *Server + func (s *Server) Close(fn func(error)) + func (s *Server) Compress(compress bool) *BroadcastOperator + func (s *Server) ConnectTimeout() time.Duration + func (s *Server) Construct(srv any, opts *ServerOptions) + func (s *Server) DisconnectSockets(status bool) + func (s *Server) EmitWithAck(ev string, args ...any) func(func([]any, error)) + func (s *Server) Encoder() parser.Encoder + func (s *Server) Engine() engine.BaseServer + func (s *Server) Except(room ...Room) *BroadcastOperator + func (s *Server) FetchSockets() func(func([]*RemoteSocket, error)) + func (s *Server) In(room ...Room) *BroadcastOperator + func (s *Server) Listen(srv any, opts *ServerOptions) *Server + func (s *Server) Local() *BroadcastOperator + func (s *Server) Of(name any, fn func(...any)) NamespaceInterface + func (s *Server) Opts() *ServerOptions + func (s *Server) Path() string + func (s *Server) Send(args ...any) *Server + func (s *Server) ServeClient() bool + func (s *Server) ServeHandler(opts *ServerOptions) http.Handler + func (s *Server) ServerSideEmit(ev string, args ...any) error + func (s *Server) ServerSideEmitWithAck(ev string, args ...any) func(func([]any, error)) + func (s *Server) SetAdapter(v AdapterConstructor) *Server + func (s *Server) SetConnectTimeout(v time.Duration) *Server + func (s *Server) SetPath(v string) *Server + func (s *Server) SetServeClient(v bool) *Server + func (s *Server) Sockets() NamespaceInterface + func (s *Server) SocketsJoin(room ...Room) + func (s *Server) SocketsLeave(room ...Room) + func (s *Server) Timeout(timeout time.Duration) *BroadcastOperator + func (s *Server) To(room ...Room) *BroadcastOperator + func (s *Server) Use(fn func(*Socket, func(*ExtendedError))) *Server + func (s *Server) Volatile() *BroadcastOperator + func (s *Server) Write(args ...any) *Server + type ServerOptions struct + func DefaultServerOptions() *ServerOptions + func (s *ServerOptions) Adapter() AdapterConstructor + func (s *ServerOptions) Assign(data ServerOptionsInterface) (ServerOptionsInterface, error) + func (s *ServerOptions) CleanupEmptyChildNamespaces() bool + func (s *ServerOptions) ConnectTimeout() time.Duration + func (s *ServerOptions) ConnectionStateRecovery() *ConnectionStateRecovery + func (s *ServerOptions) GetRawAdapter() AdapterConstructor + func (s *ServerOptions) GetRawCleanupEmptyChildNamespaces() *bool + func (s *ServerOptions) GetRawConnectTimeout() *time.Duration + func (s *ServerOptions) GetRawConnectionStateRecovery() *ConnectionStateRecovery + func (s *ServerOptions) GetRawParser() parser.Parser + func (s *ServerOptions) GetRawServeClient() *bool + func (s *ServerOptions) Parser() parser.Parser + func (s *ServerOptions) Path() string + func (s *ServerOptions) ServeClient() bool + func (s *ServerOptions) SetAdapter(adapter AdapterConstructor) + func (s *ServerOptions) SetCleanupEmptyChildNamespaces(cleanupEmptyChildNamespaces bool) + func (s *ServerOptions) SetConnectTimeout(connectTimeout time.Duration) + func (s *ServerOptions) SetConnectionStateRecovery(connectionStateRecovery *ConnectionStateRecovery) + func (s *ServerOptions) SetParser(parser parser.Parser) + func (s *ServerOptions) SetServeClient(serveClient bool) + type ServerOptionsInterface interface + Adapter func() AdapterConstructor + CleanupEmptyChildNamespaces func() bool + ConnectTimeout func() time.Duration + ConnectionStateRecovery func() *ConnectionStateRecovery + GetRawAdapter func() AdapterConstructor + GetRawCleanupEmptyChildNamespaces func() *bool + GetRawConnectTimeout func() *time.Duration + GetRawConnectionStateRecovery func() *ConnectionStateRecovery + GetRawParser func() parser.Parser + GetRawServeClient func() *bool + Parser func() parser.Parser + ServeClient func() bool + SetAdapter func(AdapterConstructor) + SetCleanupEmptyChildNamespaces func(bool) + SetConnectTimeout func(time.Duration) + SetConnectionStateRecovery func(*ConnectionStateRecovery) + SetParser func(parser.Parser) + SetServeClient func(bool) + type Session struct + MissedPackets []any + type SessionAwareAdapterBuilder struct + func (*SessionAwareAdapterBuilder) New(nsp NamespaceInterface) Adapter + type SessionToPersist struct + Data any + Pid PrivateSessionId + Rooms *types.Set[Room] + Sid SocketId + type SessionWithTimestamp struct + DisconnectedAt int64 + type Socket struct + func MakeSocket() *Socket + func NewSocket(nsp *Namespace, client *Client, auth any, previousSession *Session) *Socket + func (s *Socket) Acks() *types.Map[uint64, func([]any, error)] + func (s *Socket) Broadcast() *BroadcastOperator + func (s *Socket) Client() *Client + func (s *Socket) Compress(compress bool) *Socket + func (s *Socket) Conn() engine.Socket + func (s *Socket) Connected() bool + func (s *Socket) Construct(nsp *Namespace, client *Client, auth any, previousSession *Session) + func (s *Socket) Data() any + func (s *Socket) Disconnect(status bool) *Socket + func (s *Socket) Disconnected() bool + func (s *Socket) Emit(ev string, args ...any) error + func (s *Socket) EmitWithAck(ev string, args ...any) func(func([]any, error)) + func (s *Socket) Except(room ...Room) *BroadcastOperator + func (s *Socket) Handshake() *Handshake + func (s *Socket) Id() SocketId + func (s *Socket) In(room ...Room) *BroadcastOperator + func (s *Socket) Join(rooms ...Room) + func (s *Socket) Leave(room Room) + func (s *Socket) ListenersAny() []events.Listener + func (s *Socket) ListenersAnyOutgoing() []events.Listener + func (s *Socket) Local() *BroadcastOperator + func (s *Socket) NotifyOutgoingListeners() func(*parser.Packet) + func (s *Socket) Nsp() *Namespace + func (s *Socket) OffAny(listener events.Listener) *Socket + func (s *Socket) OffAnyOutgoing(listener events.Listener) *Socket + func (s *Socket) OnAny(listener events.Listener) *Socket + func (s *Socket) OnAnyOutgoing(listener events.Listener) *Socket + func (s *Socket) PrependAny(listener events.Listener) *Socket + func (s *Socket) PrependAnyOutgoing(listener events.Listener) *Socket + func (s *Socket) Recovered() bool + func (s *Socket) Request() *types.HttpContext + func (s *Socket) Rooms() *types.Set[Room] + func (s *Socket) Send(args ...any) *Socket + func (s *Socket) SetData(data any) + func (s *Socket) Timeout(timeout time.Duration) *Socket + func (s *Socket) To(room ...Room) *BroadcastOperator + func (s *Socket) Use(fn func([]any, func(error))) *Socket + func (s *Socket) Volatile() *Socket + func (s *Socket) Write(args ...any) *Socket + type SocketDetails interface + Data func() any + Handshake func() *Handshake + Id func() SocketId + Rooms func() *types.Set[Room] + type SocketId string + type StrictEventEmitter struct + func NewStrictEventEmitter() *StrictEventEmitter + func (s *StrictEventEmitter) Emit(ev string, args ...any) + func (s *StrictEventEmitter) EmitReserved(ev string, args ...any) + func (s *StrictEventEmitter) EmitUntyped(ev string, args ...any) + func (s *StrictEventEmitter) Listeners(ev string) []events.Listener + func (s *StrictEventEmitter) On(ev string, listeners ...events.Listener) error + func (s *StrictEventEmitter) Once(ev string, listeners ...events.Listener) error + type WriteOptions struct + PreEncoded bool + Volatile bool