emitter

package module
v0.0.0-...-72cc135 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2019 License: MIT Imports: 0 Imported by: 0

README

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

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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