Пример #1
0
func (c *channel) initializeExtensions() *msgpack.Extensions {
	exts := msgpack.NewExtensions()
	exts.SetEncoder(c.encodeExtension)
	exts.AddDecoder(1, reflect.TypeOf(&channel{}), c.decodeChannel)
	exts.AddDecoder(2, reflect.TypeOf(&byteStream{}), c.session.decodeStream)
	return exts
}
Пример #2
0
func (s *stream) initializeExtensions() *msgpack.Extensions {
	exts := msgpack.NewExtensions()
	exts.SetEncoder(s.encodeExtended)
	exts.AddDecoder(duplexStreamCode, reflect.TypeOf(&stream{}), s.decodeWStream)
	exts.AddDecoder(inboundStreamCode, reflect.TypeOf(&stream{}), s.decodeWStream)
	exts.AddDecoder(outboundStreamCode, reflect.TypeOf(&stream{}), s.decodeRStream)
	exts.AddDecoder(inboundChannelCode, reflect.TypeOf(&sender{}), s.decodeSender)
	exts.AddDecoder(outboundChannelCode, reflect.TypeOf(&receiver{}), s.decodeReceiver)
	exts.AddDecoder(timeCode, reflect.TypeOf(&time.Time{}), decodeTime)
	return exts
}