Esempio n. 1
0
func (emitter *Emitter) emit(packet map[string]interface{}) (*Emitter, error) {
	if emitter.flags["nsp"] != nil {
		packet["nsp"] = emitter.flags["nsp"]
		delete(emitter.flags, "nsp")
	}
	var pack []interface{} = make([]interface{}, 0)
	pack = append(pack, packet)
	pack = append(pack, map[string]interface{}{
		"rooms": emitter.rooms,
		"flags": emitter.flags,
	})
	buf := &bytes.Buffer{}
	enc := msgpack.NewEncoder(buf)
	error := enc.Encode(pack)
	if error != nil {
		return nil, error
	}
	emitter.Redis.Do("PUBLISH", emitter.Key, buf)
	emitter.rooms = []string{}
	emitter.flags = make(map[string]interface{})
	return emitter, nil
}
Esempio n. 2
0
func (j *MsgpackSerializer) NewEncoder(w io.Writer) ContentTypeEncoder {
	return &msgpackEncoderAdapter{msgpack.NewEncoder(w)}
}