# README
Socket.io Emitter
Library supporting send message from non-socket.io process via redis. (Mostly configured by socket.io and socket.io-redis in NodeJs)
Example
go get -u github.com/ginkcode/socket.io-emitter
import "github.com/ginkcode/socket.io-emitter"
import "github.com/go-redis/redis/v7"
func Test() {
opts := &redis.Options{Addr: "localhost:6379"}
rdWrapper, err := NewWrapperWithOptions(opts)
if err != nil {
panic("Can't create Redis wrapper")
}
emitter := NewEmitter("prefix", "/namespace", rdWrapper)
if err := emitter.To("chat").Emit("Hello world"); err != nil {
panic("Can't send message to chat room")
}
if err := emitter.Broadcast("Hello World"); err != nil {
panic("Can't broadcast message")
}
}
Notes
emitter
use its own Rooms to combine and pack the message before emitting and then reset it. Let's create new instance or check mutex lock to avoid race condition.- Can reuse redis connection by passing
redis.Client
orredis.ClusterClient
byNewWrapper()
orNewWrapperWithCluster()
# Packages
No description provided by the author
# Functions
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author