Skip to content

bugthesystem/socket.io-go-emitter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

socket.io-go-emitter

A Go implementation of socket.io-emitter

socket.io provides a hook point to easily allow you to emit events to browsers from anywhere so socket.io-go-emitter communicates with socket.io servers through redis.

GoDoc

How to use

Install

go get github.com/ziyasal/socket.io-go-emitter/emitter

API

Emitter(opts)

The following options are allowed:

  • Key: the name of the key to pub/sub events on as prefix (socket.io)
  • Host: host to connect to redis on (localhost:6379)

Important Make sure to supply theHost options.

Specifies a specific room that you want to emit to.

Initialize emitter

import "github.com/ziyasal/socket.io-go-emitter/emitter"

//....

opts := emitter.EmitterOptions{
		Host: "127.0.0.1:6379",
		Key   :"socket.io",
	}
sio := emitter.New(opts)

###Emitter#Emit(channel,message):Emitter

  sio.Emit("broadcast event", "Hello from socket.io-go-emitter")

Emitter#In(room):Emitter

  sio.In("test").Emit("broadcast event", "Hello from socket.io-go-emitter")

Emitter#To(room):Emitter

 sio.To("test").Emit("broadcast event", "Hello from socket.io-go-emitter")

Emitter#Of(namespace):Emitter

Specifies a specific namespace that you want to emit to.

 sio.Of("/nsp").Emit("broadcast event", "Hello from socket.io-go-emitter")

Bugs

If you encounter a bug, performance issue, or malfunction, please add an Issue with steps on how to reproduce the problem.

TODO

  • Add more tests
  • Add samples

Open Source Projects in Use

  • redigo by Gary Burd @garyburd
  • msgpack by Vladimir Mihailenco @vmihailenco

License

Code and documentation are available according to the MIT License (see LICENSE).

About

Go implementation of socket.io-emitter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages