Documentation ¶
Index ¶
- Constants
- Variables
- type BroadcastFlags
- type BroadcastOperator
- func (b *BroadcastOperator) Compress(compress bool) *BroadcastOperator
- func (b *BroadcastOperator) DisconnectSockets(state bool)
- func (b *BroadcastOperator) Emit(ev string, args ...any) error
- func (b *BroadcastOperator) Except(room ...socket.Room) *BroadcastOperator
- func (b *BroadcastOperator) In(room ...socket.Room) *BroadcastOperator
- func (b *BroadcastOperator) SocketsJoin(room ...socket.Room)
- func (b *BroadcastOperator) SocketsLeave(room ...socket.Room)
- func (b *BroadcastOperator) To(room ...socket.Room) *BroadcastOperator
- func (b *BroadcastOperator) Volatile() *BroadcastOperator
- type BroadcastOptions
- type Emitter
- func (e *Emitter) Compress(compress bool) *BroadcastOperator
- func (e *Emitter) DisconnectSockets(state bool)
- func (e *Emitter) Emit(ev string, args ...any) error
- func (e *Emitter) Except(room ...socket.Room) *BroadcastOperator
- func (e *Emitter) In(room ...socket.Room) *BroadcastOperator
- func (e *Emitter) Of(nsp string) *Emitter
- func (e *Emitter) ServerSideEmit(args ...any) error
- func (e *Emitter) SocketsJoin(room ...socket.Room)
- func (e *Emitter) SocketsLeave(room ...socket.Room)
- func (e *Emitter) To(room ...socket.Room) *BroadcastOperator
- func (e *Emitter) Volatile() *BroadcastOperator
- type EmitterOptions
- func (s *EmitterOptions) Assign(data EmitterOptionsInterface) (EmitterOptionsInterface, error)
- func (s *EmitterOptions) GetRawKey() *string
- func (s *EmitterOptions) GetRawParser() Parser
- func (s *EmitterOptions) Key() string
- func (s *EmitterOptions) Parser() Parser
- func (s *EmitterOptions) SetKey(key string)
- func (s *EmitterOptions) SetParser(parser Parser)
- type EmitterOptionsInterface
- type Packet
- type PacketOptions
- type Parser
- type RequestType
Constants ¶
const UID = "emitter"
Variables ¶
var RESERVED_EVENTS = types.NewSet(
"connect",
"connect_error",
"disconnect",
"disconnecting",
"newListener",
"removeListener",
)
Functions ¶
This section is empty.
Types ¶
type BroadcastFlags ¶
type BroadcastOperator ¶
type BroadcastOperator struct {
// contains filtered or unexported fields
}
func NewBroadcastOperator ¶
func NewBroadcastOperator(redisClient *redis.Client, broadcastOptions *BroadcastOptions, rooms *types.Set[socket.Room], exceptRooms *types.Set[socket.Room], flags *BroadcastFlags) *BroadcastOperator
func (*BroadcastOperator) Compress ¶
func (b *BroadcastOperator) Compress(compress bool) *BroadcastOperator
Sets the compress flag.
func (*BroadcastOperator) DisconnectSockets ¶
func (b *BroadcastOperator) DisconnectSockets(state bool)
Makes the matching socket instances disconnect
func (*BroadcastOperator) Emit ¶
func (b *BroadcastOperator) Emit(ev string, args ...any) error
Emits to all clients.
func (*BroadcastOperator) Except ¶
func (b *BroadcastOperator) Except(room ...socket.Room) *BroadcastOperator
Excludes a room when emitting.
func (*BroadcastOperator) In ¶
func (b *BroadcastOperator) In(room ...socket.Room) *BroadcastOperator
Targets a room when emitting.
func (*BroadcastOperator) SocketsJoin ¶
func (b *BroadcastOperator) SocketsJoin(room ...socket.Room)
Makes the matching socket instances join the specified rooms
func (*BroadcastOperator) SocketsLeave ¶
func (b *BroadcastOperator) SocketsLeave(room ...socket.Room)
Makes the matching socket instances leave the specified rooms
func (*BroadcastOperator) To ¶
func (b *BroadcastOperator) To(room ...socket.Room) *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 Emitter ¶
type Emitter struct {
// contains filtered or unexported fields
}
func NewEmitter ¶
func NewEmitter(redisClient *redis.Client, opts *EmitterOptions, nsps ...string) *Emitter
func (*Emitter) Compress ¶
func (e *Emitter) Compress(compress bool) *BroadcastOperator
Sets the compress flag.
compress - if `true`, compresses the sending data
func (*Emitter) DisconnectSockets ¶
Makes the matching socket instances disconnect
func (*Emitter) Except ¶
func (e *Emitter) Except(room ...socket.Room) *BroadcastOperator
Excludes a room when emitting.
func (*Emitter) In ¶
func (e *Emitter) In(room ...socket.Room) *BroadcastOperator
Targets a room when emitting.
func (*Emitter) ServerSideEmit ¶
Send a packet to the Socket.IO servers in the cluster
args - any number of serializable arguments
func (*Emitter) SocketsJoin ¶
Makes the matching socket instances join the specified rooms
func (*Emitter) SocketsLeave ¶
Makes the matching socket instances leave the specified rooms
func (*Emitter) To ¶
func (e *Emitter) To(room ...socket.Room) *BroadcastOperator
Targets a room when emitting.
func (*Emitter) Volatile ¶
func (e *Emitter) 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 EmitterOptions ¶
type EmitterOptions struct {
// contains filtered or unexported fields
}
func DefaultEmitterOptions ¶
func DefaultEmitterOptions() *EmitterOptions
func (*EmitterOptions) Assign ¶
func (s *EmitterOptions) Assign(data EmitterOptionsInterface) (EmitterOptionsInterface, error)
func (*EmitterOptions) GetRawKey ¶
func (s *EmitterOptions) GetRawKey() *string
func (*EmitterOptions) GetRawParser ¶
func (s *EmitterOptions) GetRawParser() Parser
func (*EmitterOptions) Key ¶
func (s *EmitterOptions) Key() string
func (*EmitterOptions) Parser ¶
func (s *EmitterOptions) Parser() Parser
func (*EmitterOptions) SetKey ¶
func (s *EmitterOptions) SetKey(key string)
func (*EmitterOptions) SetParser ¶
func (s *EmitterOptions) SetParser(parser Parser)
type EmitterOptionsInterface ¶
type Packet ¶
type Packet struct { Uid string `json:"uid,omitempty" msgpack:"uid,omitempty"` Type RequestType `json:"type,omitempty" msgpack:"type,omitempty"` Data any `json:"data,omitempty" msgpack:"data,omitempty"` Opts *PacketOptions `json:"opts,omitempty" msgpack:"opts,omitempty"` Close bool `json:"close,omitempty" msgpack:"close,omitempty"` Rooms []socket.Room `json:"rooms,omitempty" msgpack:"rooms,omitempty"` }
type PacketOptions ¶
type PacketOptions struct { Rooms []socket.Room `json:"rooms,omitempty" msgpack:"rooms,omitempty"` Except []socket.Room `json:"except,omitempty" msgpack:"except,omitempty"` Flags *BroadcastFlags `json:"flags,omitempty" msgpack:"flags,omitempty"` }
type RequestType ¶
type RequestType int
const ( SOCKETS RequestType = 0x0 ALL_ROOMS RequestType = 0x1 REMOTE_JOIN RequestType = 0x2 REMOTE_LEAVE RequestType = 0x3 REMOTE_DISCONNECT RequestType = 0x4 REMOTE_FETCH RequestType = 0x5 SERVER_SIDE_EMIT RequestType = 0x6 )