emitter

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: MIT Imports: 7 Imported by: 1

README

go-socketio-redis-emitter

Go implementation of socket.io-emitter using Redis interface

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MsgPackEncoderPool = sync.Pool{
		New: func() any {
			encoder := msgpack.NewEncoder(nil)
			encoder.UseCompactInts(true)
			encoder.UseCompactFloats(true)
			return encoder
		},
	}
	MsgPackDecoderPool = sync.Pool{
		New: func() any {
			return msgpack.NewDecoder(nil)
		},
	}
)

Functions

func GetMsgPackDecoder added in v0.0.5

func GetMsgPackDecoder(adaptJSON bool) *msgpack.Decoder

func GetMsgPackEncoder added in v0.0.4

func GetMsgPackEncoder() *msgpack.Encoder

func MsgPackMarshal added in v0.0.4

func MsgPackMarshal(obj any, adaptJSON bool) ([]byte, error)

func MsgPackUnmarshal added in v0.0.5

func MsgPackUnmarshal(data []byte, obj any, adaptJSON bool) error

func PutMsgPackDecoder added in v0.0.5

func PutMsgPackDecoder(decoder *msgpack.Decoder)

func PutMsgPackEncoder added in v0.0.4

func PutMsgPackEncoder(encoder *msgpack.Encoder)

Types

type Emitter

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

Emitter Socket.IO redis base emitter

func NewEmitter

func NewEmitter(opts *Options) *Emitter

NewEmitter Emitter constructor

func (*Emitter) Broadcast

func (e *Emitter) Broadcast() *Emitter

Broadcast flag

func (*Emitter) Close

func (e *Emitter) Close()

Close release redis client

func (*Emitter) Emit

func (e *Emitter) Emit(ctx context.Context, data ...interface{}) (*Emitter, error)

Emit Send the packet

func (*Emitter) In

func (e *Emitter) In(room string) *Emitter

In Limit emission to a certain `room`

func (*Emitter) JSON

func (e *Emitter) JSON() *Emitter

JSON flag

func (*Emitter) Of

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

Of Limit emission to certain `namespace`

func (*Emitter) Reset added in v0.0.6

func (e *Emitter) Reset()

Reset session data of emitter

func (*Emitter) To

func (e *Emitter) To(room string) *Emitter

To Limit emission to a certain `room`

func (*Emitter) Volatile

func (e *Emitter) Volatile() *Emitter

Volatile flag

type EmitterSession added in v0.0.6

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

type Options

type Options struct {
	// the name of the key to pub/sub events on as prefix (socket.io)
	Key string

	// Redis instance
	Redis redis.UniversalClient
}

Options ...

Jump to

Keyboard shortcuts

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