emitter

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const UID adapter.ServerId = "emitter"

Variables

View Source
var RESERVED_EVENTS = types.NewSet(
	"connect",
	"connect_error",
	"disconnect",
	"disconnecting",
	"newListener",
	"removeListener",
)

Functions

This section is empty.

Types

type BroadcastOperator

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

func MakeBroadcastOperator

func MakeBroadcastOperator() *BroadcastOperator

func NewBroadcastOperator

func NewBroadcastOperator(redisClient *_types.RedisClient, broadcastOptions *BroadcastOptions, rooms *types.Set[socket.Room], exceptRooms *types.Set[socket.Room], flags *socket.BroadcastFlags) *BroadcastOperator

func (*BroadcastOperator) Compress

func (b *BroadcastOperator) Compress(compress bool) *BroadcastOperator

Sets the compress flag.

func (*BroadcastOperator) Construct

func (b *BroadcastOperator) Construct(redisClient *_types.RedisClient, broadcastOptions *BroadcastOptions, rooms *types.Set[socket.Room], exceptRooms *types.Set[socket.Room], flags *socket.BroadcastFlags)

func (*BroadcastOperator) DisconnectSockets

func (b *BroadcastOperator) DisconnectSockets(state bool) error

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

Targets a room when emitting.

func (*BroadcastOperator) SocketsJoin

func (b *BroadcastOperator) SocketsJoin(rooms ...socket.Room) error

Makes the matching socket instances join the specified rooms

func (*BroadcastOperator) SocketsLeave

func (b *BroadcastOperator) SocketsLeave(rooms ...socket.Room) error

Makes the matching socket instances leave the specified rooms

func (*BroadcastOperator) To

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 {
	Nsp              string
	BroadcastChannel string
	RequestChannel   string
	Parser           types.Parser
}

type Emitter

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

func MakeEmitter

func MakeEmitter() *Emitter

func NewEmitter

func NewEmitter(redisClient *types.RedisClient, 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) Construct

func (e *Emitter) Construct(redisClient *types.RedisClient, opts *EmitterOptions, nsps ...string)

func (*Emitter) DisconnectSockets

func (e *Emitter) DisconnectSockets(state bool) error

Makes the matching socket instances disconnect

func (*Emitter) Emit

func (e *Emitter) Emit(ev string, args ...any) error

Emits to all clients.

func (*Emitter) Except

func (e *Emitter) Except(rooms ...socket.Room) *BroadcastOperator

Excludes a room when emitting.

func (*Emitter) In

func (e *Emitter) In(rooms ...socket.Room) *BroadcastOperator

Targets a room when emitting.

func (*Emitter) Of

func (e *Emitter) Of(nsp string) *Emitter

Return a new emitter for the given namespace.

func (*Emitter) ServerSideEmit

func (e *Emitter) ServerSideEmit(args ...any) error

Send a packet to the Socket.IO servers in the cluster

func (*Emitter) SocketsJoin

func (e *Emitter) SocketsJoin(rooms ...socket.Room) error

Makes the matching socket instances join the specified rooms

func (*Emitter) SocketsLeave

func (e *Emitter) SocketsLeave(rooms ...socket.Room) error

Makes the matching socket instances leave the specified rooms

func (*Emitter) To

func (e *Emitter) To(rooms ...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 (*EmitterOptions) GetRawKey

func (s *EmitterOptions) GetRawKey() *string

func (*EmitterOptions) GetRawParser

func (s *EmitterOptions) GetRawParser() types.Parser

func (*EmitterOptions) Key

func (s *EmitterOptions) Key() string

Default: "socket.io"

func (*EmitterOptions) Parser

func (s *EmitterOptions) Parser() types.Parser

The parser to use for encoding messages sent to Redis. Defaults to msgpack, a MessagePack implementation.

func (*EmitterOptions) SetKey

func (s *EmitterOptions) SetKey(key string)

func (*EmitterOptions) SetParser

func (s *EmitterOptions) SetParser(parser types.Parser)

type EmitterOptionsInterface

type EmitterOptionsInterface interface {
	SetKey(string)
	GetRawKey() *string
	Key() string

	SetParser(types.Parser)
	GetRawParser() types.Parser
	Parser() types.Parser
}

type Packet added in v1.1.1

type Packet = types.RedisPacket

type Request added in v1.1.1

type Request = types.RedisRequest

type Response added in v1.1.1

type Response = types.RedisResponse

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL