func subscribe(emitter *emission.Emitter) {
	conn, _ := redis.Dial("tcp", ":6379")
	channel := redis.PubSubConn{conn}
	channel.Subscribe(CHANNEL_NAME)
	for {
		reply := channel.Receive()
		switch parsed := reply.(type) {
		case redis.Message:
			message := string(parsed.Data)
			emitter.Emit("message", message)
		}
	}
}
Ejemplo n.º 2
0
// Trigger events on an external event emitter
func (u *Peer) NotifyChannel(e *event.E, emitter *emission.Emitter) {
	emitter.Emit(e.Action, e)
}