emitter

package module
v0.0.0-...-3549384 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2021 License: MIT Imports: 4 Imported by: 0

README

socket.io-emitter-go

Go implementation of socket.io-emitter

Install

$ go get github.com/stackcats/socket.io-emitter-go

Example

opts := &emitter.Options{}
socket := emitter.NewEmitter(opts)
defer socket.Close()
socket.Broadcast().Emit("message", "Hello World")

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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(data ...interface{}) (*Emitter, error)

Emit Send the packet

func (*Emitter) EmitToRoom

func (e *Emitter) EmitToRoom(room string, data ...interface{}) (*Emitter, error)

func (*Emitter) EmitToRooms

func (e *Emitter) EmitToRooms(rooms []string, data ...interface{}) (*Emitter, error)

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) 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 Options

type Options struct {
	// host to connect to redis on (localhost)
	Host string
	// port to connect to redis on (6379)
	Port int
	// password to connect to redis
	Password string
	// DB
	DB int
	// the name of the key to pub/sub events on as prefix (socket.io)
	Key string
	// unix domain socket to connect to redis on ("/tmp/redis.sock")
	Socket string
	// redis client
	Redis *redis.Client
}

Options ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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