Documentation
¶
Index ¶
- Variables
- type Adapter
- type BroadcastFlags
- type BroadcastOperator
- func (b *BroadcastOperator) AllSockets() (*types.Set, error)
- func (b *BroadcastOperator) Compress(compress bool) *BroadcastOperator
- func (b *BroadcastOperator) DisconnectSockets(status bool)
- func (b *BroadcastOperator) Emit(ev string, args ...interface{}) error
- func (b *BroadcastOperator) Except(room ...string) *BroadcastOperator
- func (b *BroadcastOperator) FetchSockets() (remoteSockets []*RemoteSocket)
- func (b *BroadcastOperator) In(room ...string) *BroadcastOperator
- func (b *BroadcastOperator) Local() *BroadcastOperator
- func (b *BroadcastOperator) SocketsJoin(room ...string)
- func (b *BroadcastOperator) SocketsLeave(room ...string)
- func (b *BroadcastOperator) Timeout(timeout time.Duration) *BroadcastOperator
- func (b *BroadcastOperator) To(room ...string) *BroadcastOperator
- func (b *BroadcastOperator) Volatile() *BroadcastOperator
- type BroadcastOptions
- type Client
- type ExtendedError
- type Handshake
- type Namespace
- func (n *Namespace) Adapter() Adapter
- func (n *Namespace) Add(client *Client, query interface{}, fn func(*Socket)) *Socket
- func (n *Namespace) AllSockets() (*types.Set, error)
- func (n *Namespace) Compress(compress bool) *BroadcastOperator
- func (n *Namespace) DisconnectSockets(status bool)
- func (n *Namespace) Emit(ev string, args ...interface{}) error
- func (n *Namespace) EventEmitter() *StrictEventEmitter
- func (n *Namespace) Except(room ...string) *BroadcastOperator
- func (n *Namespace) FetchSockets() ([]*RemoteSocket, error)
- func (n *Namespace) Ids() uint64
- func (n *Namespace) In(room ...string) *BroadcastOperator
- func (n *Namespace) Local() *BroadcastOperator
- func (n *Namespace) Name() string
- func (n *Namespace) Send(args ...interface{}) NamespaceInterface
- func (n *Namespace) Server() *Server
- func (n *Namespace) ServerSideEmit(ev string, args ...interface{}) error
- func (n *Namespace) Sockets() *sync.Map
- func (n *Namespace) SocketsJoin(room ...string)
- func (n *Namespace) SocketsLeave(room ...string)
- func (n *Namespace) Timeout(timeout time.Duration) *BroadcastOperator
- func (n *Namespace) To(room ...string) *BroadcastOperator
- func (n *Namespace) Use(fn func(*Socket, func(*ExtendedError))) NamespaceInterface
- func (n *Namespace) Volatile() *BroadcastOperator
- func (n *Namespace) Write(args ...interface{}) NamespaceInterface
- type NamespaceInterface
- type ParentNamespace
- type ParentNspNameMatchFn
- type RemoteSocket
- func (r *RemoteSocket) Data() interface{}
- func (r *RemoteSocket) Disconnect(status bool) *RemoteSocket
- func (r *RemoteSocket) Emit(ev string, args ...interface{}) error
- func (r *RemoteSocket) Handshake() *Handshake
- func (r *RemoteSocket) Id() string
- func (r *RemoteSocket) Join(room ...string)
- func (r *RemoteSocket) Leave(room ...string)
- func (r *RemoteSocket) Rooms() *types.Set
- type Server
- func (s *Server) Adapter() Adapter
- func (s *Server) AllSockets() (*types.Set, error)
- func (s *Server) Attach(srv interface{}, opts *ServerOptions) *Server
- func (s *Server) Bind(egs engine.Server) *Server
- func (s *Server) Close(fn func())
- func (s *Server) Compress(compress bool) *BroadcastOperator
- func (s *Server) ConnectTimeout() time.Duration
- func (s *Server) DisconnectSockets(status bool)
- func (s *Server) Encoder() parser.Encoder
- func (s *Server) Engine() engine.Server
- func (s *Server) Except(room ...string) *BroadcastOperator
- func (s *Server) FetchSockets() ([]*RemoteSocket, error)
- func (s *Server) In(room ...string) *BroadcastOperator
- func (s *Server) Listen(srv interface{}, opts *ServerOptions) *Server
- func (s *Server) Local() *BroadcastOperator
- func (s *Server) Of(name interface{}, fn func(...interface{})) NamespaceInterface
- func (s *Server) Path() string
- func (s *Server) Send(args ...interface{}) *Server
- func (s *Server) ServeClient() bool
- func (s *Server) ServeHandler(opts *ServerOptions) http.Handler
- func (s *Server) ServerSideEmit(ev string, args ...interface{}) error
- func (s *Server) SetAdapter(v Adapter) *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 ...string)
- func (s *Server) SocketsLeave(room ...string)
- func (s *Server) Timeout(timeout time.Duration) *BroadcastOperator
- func (s *Server) To(room ...string) *BroadcastOperator
- func (s *Server) Use(fn func(*Socket, func(*ExtendedError))) *Server
- func (s *Server) Volatile() *BroadcastOperator
- func (s *Server) Write(args ...interface{}) *Server
- type ServerOptions
- func (s *ServerOptions) Adapter() Adapter
- func (s *ServerOptions) Assign(data ServerOptionsInterface) (ServerOptionsInterface, error)
- func (s *ServerOptions) ConnectTimeout() time.Duration
- func (s *ServerOptions) GetRawAdapter() Adapter
- func (s *ServerOptions) GetRawConnectTimeout() *time.Duration
- 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 Adapter)
- func (s *ServerOptions) SetConnectTimeout(connectTimeout time.Duration)
- func (s *ServerOptions) SetParser(parser parser.Parser)
- func (s *ServerOptions) SetServeClient(serveClient bool)
- type ServerOptionsInterface
- type Set
- type Socket
- func (s *Socket) Acks() *sync.Map
- 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) Data() interface{}
- func (s *Socket) Disconnect(status bool) *Socket
- func (s *Socket) Disconnected() bool
- func (s *Socket) Emit(ev string, args ...interface{}) error
- func (s *Socket) Except(room ...string) *BroadcastOperator
- func (s *Socket) Handshake() *Handshake
- func (s *Socket) Id() string
- func (s *Socket) In(room ...string) *BroadcastOperator
- func (s *Socket) Join(rooms ...string)
- func (s *Socket) Leave(room string)
- 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) Request() *types.HttpContext
- func (s *Socket) Rooms() *types.Set
- func (s *Socket) Send(args ...interface{}) *Socket
- func (s *Socket) SetData(data interface{})
- func (s *Socket) Timeout(timeout time.Duration) *Socket
- func (s *Socket) To(room ...string) *BroadcastOperator
- func (s *Socket) Use(fn func([]interface{}, func(error))) *Socket
- func (s *Socket) Volatile() *Socket
- func (s *Socket) Write(args ...interface{}) *Socket
- type SocketDetails
- type StrictEventEmitter
- func (s *StrictEventEmitter) Emit(ev string, args ...interface{})
- func (s *StrictEventEmitter) EmitReserved(ev string, args ...interface{})
- func (s *StrictEventEmitter) EmitUntyped(ev string, args ...interface{})
- 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 Void
- type WriteOptions
Constants ¶
This section is empty.
Variables ¶
var NAMESPACE_RESERVED_EVENTS = types.NewSet("connect", "connection", "new_namespace")
var (
SOCKET_RESERVED_EVENTS = types.NewSet("connect", "connect_error", "disconnect", "disconnecting", "newListener", "removeListener")
)
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter interface {
New(NamespaceInterface) Adapter
Rooms() *sync.Map
Sids() *sync.Map
Nsp() NamespaceInterface
// To be overridden
Init()
// To be overridden
Close()
// Returns the number of Socket.IO servers in the cluster
ServerCount() int64
// Adds a socket to a list of room.
AddAll(string, *types.Set)
// Removes a socket from a room.
Del(string, string)
// Removes a socket from all rooms it's joined.
DelAll(string)
SetBroadcast(func(*parser.Packet, *BroadcastOptions))
// Broadcasts a packet.
//
// Options:
// - `Flags` {*BroadcastFlags} flags for this packet
// - `Except` {*types.Set[Room]} sids that should be excluded
// - `Rooms` {*types.Set[Room]} list of rooms to broadcast to
Broadcast(*parser.Packet, *BroadcastOptions)
// Broadcasts a packet and expects multiple acknowledgements.
//
// Options:
// - `Flags` {*BroadcastFlags} flags for this packet
// - `Except` {*types.Set[Room]} sids that should be excluded
// - `Rooms` {*types.Set[Room]} list of rooms to broadcast to
BroadcastWithAck(*parser.Packet, *BroadcastOptions, func(uint64), func(...interface{}))
// Gets a list of sockets by sid.
Sockets(*types.Set) *types.Set
// Gets the list of rooms a given socket has joined.
SocketRooms(string) *types.Set
// Returns the matching socket instances
FetchSockets(*BroadcastOptions) []interface{}
// Makes the matching socket instances join the specified rooms
AddSockets(*BroadcastOptions, []string)
// Makes the matching socket instances leave the specified rooms
DelSockets(*BroadcastOptions, []string)
// Makes the matching socket instances disconnect
DisconnectSockets(*BroadcastOptions, bool)
// Send a packet to the other Socket.IO servers in the cluster
ServerSideEmit(string, ...interface{}) error
}
type BroadcastFlags ¶
type BroadcastOperator ¶
type BroadcastOperator struct {
// contains filtered or unexported fields
}
func NewBroadcastOperator ¶
func NewBroadcastOperator(adapter Adapter, rooms *types.Set, exceptRooms *types.Set, flags *BroadcastFlags) *BroadcastOperator
func (*BroadcastOperator) AllSockets ¶
func (b *BroadcastOperator) AllSockets() (*types.Set, error)
Gets a list of clients.
func (*BroadcastOperator) Compress ¶
func (b *BroadcastOperator) Compress(compress bool) *BroadcastOperator
Sets the compress flag.
func (*BroadcastOperator) DisconnectSockets ¶
func (b *BroadcastOperator) DisconnectSockets(status bool)
Makes the matching socket instances disconnect
func (*BroadcastOperator) Emit ¶
func (b *BroadcastOperator) Emit(ev string, args ...interface{}) error
Emits to all clients.
func (*BroadcastOperator) Except ¶
func (b *BroadcastOperator) Except(room ...string) *BroadcastOperator
Excludes a room when emitting.
func (*BroadcastOperator) FetchSockets ¶
func (b *BroadcastOperator) FetchSockets() (remoteSockets []*RemoteSocket)
Returns the matching socket instances
func (*BroadcastOperator) In ¶
func (b *BroadcastOperator) In(room ...string) *BroadcastOperator
Targets a room when emitting.
func (*BroadcastOperator) Local ¶
func (b *BroadcastOperator) Local() *BroadcastOperator
Sets a modifier for a subsequent event emission that the event data will only be broadcast to the current node.
func (*BroadcastOperator) SocketsJoin ¶
func (b *BroadcastOperator) SocketsJoin(room ...string)
Makes the matching socket instances join the specified rooms
func (*BroadcastOperator) SocketsLeave ¶
func (b *BroadcastOperator) SocketsLeave(room ...string)
Makes the matching socket instances leave the specified rooms
func (*BroadcastOperator) Timeout ¶
func (b *BroadcastOperator) Timeout(timeout time.Duration) *BroadcastOperator
Adds a timeout in milliseconds for the next operation
<pre><code>
io.Timeout(1000 * time.Millisecond).Emit("some-event", func(args ...any) {
// ...
});
</pre></code>
func (*BroadcastOperator) To ¶
func (b *BroadcastOperator) To(room ...string) *BroadcastOperator
Targets a room when emitting.
func (*BroadcastOperator) Volatile ¶
func (b *BroadcastOperator) Volatile() *BroadcastOperator
Sets a modifier for a subsequent event emission that the event data may be lost if the client is not ready to receive messages (because of network slowness or other issues, or because they’re connected through long polling and is in the middle of a request-response cycle).
type BroadcastOptions ¶
type BroadcastOptions struct {
Rooms *types.Set
Except *types.Set
Flags *BroadcastFlags
}
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) Request ¶
func (c *Client) Request() *types.HttpContext
func (*Client) WriteToEngine ¶
func (c *Client) WriteToEngine(encodedPackets []types.BufferInterface, opts *WriteOptions)
type ExtendedError ¶
type ExtendedError struct {
// contains filtered or unexported fields
}
func NewExtendedError ¶
func NewExtendedError(message string, data interface{}) *ExtendedError
func (*ExtendedError) Data ¶
func (e *ExtendedError) Data() interface{}
func (*ExtendedError) Err ¶
func (e *ExtendedError) Err() error
func (*ExtendedError) Error ¶
func (e *ExtendedError) Error() string
type Handshake ¶
type Handshake struct {
// The headers sent as part of the handshake
Headers *utils.ParameterBag
// The date of creation (as string)
Time string
// The ip of the client
Address string
// Whether the connection is cross-domain
Xdomain bool
// Whether the connection is secure
Secure bool
// The date of creation (as unix timestamp)
Issued int64
// The request URL string
Url string
// The query object
Query *utils.ParameterBag
// The auth object
Auth interface{}
}
type Namespace ¶
type Namespace struct {
*StrictEventEmitter
// contains filtered or unexported fields
}
func NewNamespace ¶
Namespace constructor.
func (*Namespace) AllSockets ¶
Gets a list of clients.
func (*Namespace) Compress ¶
func (n *Namespace) Compress(compress bool) *BroadcastOperator
Sets the compress flag.
func (*Namespace) DisconnectSockets ¶
Makes the matching socket instances disconnect
func (*Namespace) EventEmitter ¶
func (n *Namespace) EventEmitter() *StrictEventEmitter
func (*Namespace) Except ¶
func (n *Namespace) Except(room ...string) *BroadcastOperator
Excludes a room when emitting.
func (*Namespace) FetchSockets ¶
func (n *Namespace) FetchSockets() ([]*RemoteSocket, error)
Returns the matching socket instances
func (*Namespace) In ¶
func (n *Namespace) In(room ...string) *BroadcastOperator
Targets a room when emitting.
func (*Namespace) Local ¶
func (n *Namespace) Local() *BroadcastOperator
Sets a modifier for a subsequent event emission that the event data will only be broadcast to the current node.
func (*Namespace) Send ¶
func (n *Namespace) Send(args ...interface{}) NamespaceInterface
Sends a `message` event to all clients.
func (*Namespace) ServerSideEmit ¶
Emit a packet to other Socket.IO servers
func (*Namespace) SocketsJoin ¶
Makes the matching socket instances join the specified rooms
func (*Namespace) SocketsLeave ¶
Makes the matching socket instances leave the specified rooms
func (*Namespace) Timeout ¶
func (n *Namespace) Timeout(timeout time.Duration) *BroadcastOperator
Adds a timeout in milliseconds for the next operation
<pre><code>
io.Timeout(1000 * time.Millisecond).Emit("some-event", func(args ...any) {
// ...
});
</pre></code>
func (*Namespace) To ¶
func (n *Namespace) To(room ...string) *BroadcastOperator
Targets a room when emitting.
func (*Namespace) Use ¶
func (n *Namespace) Use(fn func(*Socket, func(*ExtendedError))) NamespaceInterface
Sets up namespace middleware.
func (*Namespace) Volatile ¶
func (n *Namespace) Volatile() *BroadcastOperator
Sets a modifier for a subsequent event emission that the event data may be lost if the client is not ready to receive messages (because of network slowness or other issues, or because they’re connected through long polling and is in the middle of a request-response cycle).
func (*Namespace) Write ¶
func (n *Namespace) Write(args ...interface{}) NamespaceInterface
Sends a `message` event to all clients.
type NamespaceInterface ¶
type NamespaceInterface interface {
EventEmitter() *StrictEventEmitter
On(string, ...events.Listener) error
Once(string, ...events.Listener) error
EmitReserved(string, ...interface{})
EmitUntyped(string, ...interface{})
Listeners(string) []events.Listener
Sockets() *sync.Map
Server() *Server
Adapter() Adapter
Name() string
Ids() uint64
// Sets up namespace middleware.
Use(func(*Socket, func(*ExtendedError))) NamespaceInterface
// Targets a room when emitting.
To(...string) *BroadcastOperator
// Targets a room when emitting.
In(...string) *BroadcastOperator
// Excludes a room when emitting.
Except(...string) *BroadcastOperator
// Adds a new client.
Add(*Client, interface{}, func(*Socket)) *Socket
// Emits to all clients.
Emit(string, ...interface{}) error
// Sends a `message` event to all clients.
Send(...interface{}) NamespaceInterface
// Sends a `message` event to all clients.
Write(...interface{}) NamespaceInterface
// Emit a packet to other Socket.IO servers
ServerSideEmit(string, ...interface{}) error
// Gets a list of clients.
AllSockets() (*types.Set, error)
// Sets the compress flag.
Compress(bool) *BroadcastOperator
// Sets a modifier for a subsequent event emission that the event data may be lost if the client is not ready to
// receive messages (because of network slowness or other issues, or because they’re connected through long polling
// and is in the middle of a request-response cycle).
Volatile() *BroadcastOperator
// Sets a modifier for a subsequent event emission that the event data will only be broadcast to the current node.
Local() *BroadcastOperator
// Adds a timeout in milliseconds for the next operation
//
// <pre><code>
//
// io.Timeout(1000 * time.Millisecond).Emit("some-event", func(args ...any) {
// // ...
// });
//
// </pre></code>
Timeout(time.Duration) *BroadcastOperator
// Returns the matching socket instances
FetchSockets() ([]*RemoteSocket, error)
// Makes the matching socket instances join the specified rooms
SocketsJoin(...string)
// Makes the matching socket instances leave the specified rooms
SocketsLeave(...string)
// Makes the matching socket instances disconnect
DisconnectSockets(bool)
}
type ParentNamespace ¶
type ParentNamespace struct {
*Namespace
// contains filtered or unexported fields
}
func NewParentNamespace ¶
func NewParentNamespace(server *Server) *ParentNamespace
func (*ParentNamespace) CreateChild ¶
func (p *ParentNamespace) CreateChild(name string) *Namespace
func (*ParentNamespace) Emit ¶
func (p *ParentNamespace) Emit(ev string, args ...interface{}) error
func (*ParentNamespace) FetchSockets ¶
func (p *ParentNamespace) FetchSockets() ([]*RemoteSocket, error)
type ParentNspNameMatchFn ¶
type RemoteSocket ¶
type RemoteSocket struct {
// contains filtered or unexported fields
}
func NewRemoteSocket ¶
func NewRemoteSocket(adapter Adapter, details SocketDetails) *RemoteSocket
func (*RemoteSocket) Data ¶
func (r *RemoteSocket) Data() interface{}
func (*RemoteSocket) Disconnect ¶
func (r *RemoteSocket) Disconnect(status bool) *RemoteSocket
Disconnects this client.
func (*RemoteSocket) Emit ¶
func (r *RemoteSocket) Emit(ev string, args ...interface{}) error
func (*RemoteSocket) Handshake ¶
func (r *RemoteSocket) Handshake() *Handshake
func (*RemoteSocket) Id ¶
func (r *RemoteSocket) Id() string
func (*RemoteSocket) Rooms ¶
func (r *RemoteSocket) Rooms() *types.Set
type Server ¶
type Server struct {
*StrictEventEmitter
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(srv interface{}, opts *ServerOptions) *Server
func (*Server) AllSockets ¶
Gets a list of socket ids.
func (*Server) Attach ¶
func (s *Server) Attach(srv interface{}, opts *ServerOptions) *Server
Attaches socket.io to a server or port.
func (*Server) Compress ¶
func (s *Server) Compress(compress bool) *BroadcastOperator
Sets the compress flag.
func (*Server) ConnectTimeout ¶
func (*Server) DisconnectSockets ¶
Makes the matching socket instances disconnect
func (*Server) Except ¶
func (s *Server) Except(room ...string) *BroadcastOperator
Excludes a room when emitting.
func (*Server) FetchSockets ¶
func (s *Server) FetchSockets() ([]*RemoteSocket, error)
Returns the matching socket instances
func (*Server) In ¶
func (s *Server) In(room ...string) *BroadcastOperator
Targets a room when emitting.
func (*Server) Listen ¶
func (s *Server) Listen(srv interface{}, opts *ServerOptions) *Server
Attaches socket.io to a server or port.
func (*Server) Local ¶
func (s *Server) Local() *BroadcastOperator
Sets a modifier for a subsequent event emission that the event data will only be broadcast to the current node.
func (*Server) Of ¶
func (s *Server) Of(name interface{}, fn func(...interface{})) NamespaceInterface
Looks up a namespace.
func (*Server) ServeClient ¶
func (*Server) ServeHandler ¶
func (s *Server) ServeHandler(opts *ServerOptions) http.Handler
func (*Server) ServerSideEmit ¶
Emit a packet to other Socket.IO servers
func (*Server) SetAdapter ¶
Sets the adapter for rooms.
func (*Server) SetConnectTimeout ¶
Set the delay after which a client without namespace is closed
func (*Server) SetServeClient ¶
Sets/gets whether client code is being served.
func (*Server) Sockets ¶
func (s *Server) Sockets() NamespaceInterface
func (*Server) SocketsJoin ¶
Makes the matching socket instances join the specified rooms
func (*Server) SocketsLeave ¶
Makes the matching socket instances leave the specified rooms
func (*Server) Timeout ¶
func (s *Server) Timeout(timeout time.Duration) *BroadcastOperator
Adds a timeout in milliseconds for the next operation
<pre><code>
io.Timeout(1000 * time.Millisecond).Emit("some-event", func(args ...any) {
// ...
});
</pre></code>
func (*Server) To ¶
func (s *Server) To(room ...string) *BroadcastOperator
Targets a room when emitting.
func (*Server) Use ¶
func (s *Server) Use(fn func(*Socket, func(*ExtendedError))) *Server
Sets up namespace middleware.
func (*Server) Volatile ¶
func (s *Server) Volatile() *BroadcastOperator
Sets a modifier for a subsequent event emission that the event data may be lost if the client is not ready to receive messages (because of network slowness or other issues, or because they’re connected through long polling and is in the middle of a request-response cycle).
type ServerOptions ¶
type ServerOptions struct {
config.ServerOptions
config.AttachOptions
// contains filtered or unexported fields
}
func DefaultServerOptions ¶
func DefaultServerOptions() *ServerOptions
func (*ServerOptions) Adapter ¶
func (s *ServerOptions) Adapter() Adapter
func (*ServerOptions) Assign ¶
func (s *ServerOptions) Assign(data ServerOptionsInterface) (ServerOptionsInterface, error)
func (*ServerOptions) ConnectTimeout ¶
func (s *ServerOptions) ConnectTimeout() time.Duration
func (*ServerOptions) GetRawAdapter ¶
func (s *ServerOptions) GetRawAdapter() Adapter
func (*ServerOptions) GetRawConnectTimeout ¶
func (s *ServerOptions) GetRawConnectTimeout() *time.Duration
func (*ServerOptions) GetRawParser ¶
func (s *ServerOptions) GetRawParser() parser.Parser
func (*ServerOptions) GetRawServeClient ¶
func (s *ServerOptions) GetRawServeClient() *bool
func (*ServerOptions) Parser ¶
func (s *ServerOptions) Parser() parser.Parser
func (*ServerOptions) Path ¶
func (s *ServerOptions) Path() string
func (*ServerOptions) ServeClient ¶
func (s *ServerOptions) ServeClient() bool
func (*ServerOptions) SetAdapter ¶
func (s *ServerOptions) SetAdapter(adapter Adapter)
func (*ServerOptions) SetConnectTimeout ¶
func (s *ServerOptions) SetConnectTimeout(connectTimeout time.Duration)
func (*ServerOptions) SetParser ¶
func (s *ServerOptions) SetParser(parser parser.Parser)
func (*ServerOptions) SetServeClient ¶
func (s *ServerOptions) SetServeClient(serveClient bool)
type ServerOptionsInterface ¶
type ServerOptionsInterface interface {
config.ServerOptionsInterface
config.AttachOptionsInterface
SetServeClient(serveClient bool)
GetRawServeClient() *bool
ServeClient() bool
SetAdapter(adapter Adapter)
GetRawAdapter() Adapter
Adapter() Adapter
SetParser(parser parser.Parser)
GetRawParser() parser.Parser
Parser() parser.Parser
SetConnectTimeout(connectTimeout time.Duration)
GetRawConnectTimeout() *time.Duration
ConnectTimeout() time.Duration
}
type Socket ¶
type Socket struct {
*StrictEventEmitter
// contains filtered or unexported fields
}
func (*Socket) Broadcast ¶
func (s *Socket) Broadcast() *BroadcastOperator
Sets a modifier for a subsequent event emission that the event data will only be broadcast to every sockets but the sender.
func (*Socket) Conn ¶
A reference to the underlying Client transport connection (Engine.IO Socket object).
func (*Socket) Disconnect ¶
Disconnects this client.
func (*Socket) Disconnected ¶
Whether the socket is currently disconnected
func (*Socket) Except ¶
func (s *Socket) Except(room ...string) *BroadcastOperator
Excludes a room when broadcasting.
func (*Socket) In ¶
func (s *Socket) In(room ...string) *BroadcastOperator
Targets a room when broadcasting.
func (*Socket) ListenersAny ¶
Returns an array of listeners that are listening for any event that is specified. This array can be manipulated, e.g. to remove listeners.
func (*Socket) ListenersAnyOutgoing ¶
Returns an array of listeners that are listening for any event that is specified. This array can be manipulated, e.g. to remove listeners.
func (*Socket) Local ¶
func (s *Socket) Local() *BroadcastOperator
Sets a modifier for a subsequent event emission that the event data will only be broadcast to the current node.
func (*Socket) NotifyOutgoingListeners ¶
func (*Socket) OffAnyOutgoing ¶
Removes the listener that will be fired when any event is emitted.
<pre><code>
handler := func(args ...any) {
fmt.Println(args)
}
socket.OnAnyOutgoing(handler)
then later socket.OffAnyOutgoing(handler)
</pre></code>
func (*Socket) OnAny ¶
Adds a listener that will be fired when any event is received. The event name is passed as the first argument to the callback.
func (*Socket) OnAnyOutgoing ¶
Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the callback.
<pre><code>
socket.OnAnyOutgoing(events.Listener {
fmt.Println(args)
})
</pre></code>
func (*Socket) PrependAny ¶
Adds a listener that will be fired when any event is received. The event name is passed as the first argument to the callback. The listener is added to the beginning of the listeners array.
func (*Socket) PrependAnyOutgoing ¶
Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the callback. The listener is added to the beginning of the listeners array.
<pre><code>
socket.PrependAnyOutgoing(events.Listener {
fmt.Println(args)
})
</pre></code>
func (*Socket) Request ¶
func (s *Socket) Request() *types.HttpContext
A reference to the request that originated the underlying Engine.IO Socket.
func (*Socket) Timeout ¶
Sets a modifier for a subsequent event emission that the callback will be called with an error when the given number of milliseconds have elapsed without an acknowledgement from the client:
```
socket.Timeout(5000 * time.Millisecond).Emit("my-event", func(args ...any) {
if args[0] != nil {
// the client did not acknowledge the event in the given delay
}
})
```
func (*Socket) To ¶
func (s *Socket) To(room ...string) *BroadcastOperator
Targets a room when broadcasting.
type SocketDetails ¶
type StrictEventEmitter ¶
type StrictEventEmitter struct {
events.EventEmitter
}
Strictly typed version of an `EventEmitter`. A `TypedEventEmitter` takes type parameters for mappings of event names to event data types, and strictly types method calls to the `EventEmitter` according to these event maps.
func NewStrictEventEmitter ¶
func NewStrictEventEmitter() *StrictEventEmitter
func (*StrictEventEmitter) Emit ¶
func (s *StrictEventEmitter) Emit(ev string, args ...interface{})
Emits an event.
func (*StrictEventEmitter) EmitReserved ¶
func (s *StrictEventEmitter) EmitReserved(ev string, args ...interface{})
Emits a reserved event.
This method is `protected`, so that only a class extending `StrictEventEmitter` can emit its own reserved events.
func (*StrictEventEmitter) EmitUntyped ¶
func (s *StrictEventEmitter) EmitUntyped(ev string, args ...interface{})
Emits an event.
This method is `protected`, so that only a class extending `StrictEventEmitter` can get around the strict typing. This is useful for calling `emit.apply`, which can be called as `emitUntyped.apply`.
func (*StrictEventEmitter) Listeners ¶
func (s *StrictEventEmitter) Listeners(ev string) []events.Listener
Returns the listeners listening to an event.