Documentation
¶
Index ¶
- Constants
- Variables
- type DefaultTcpProtocol
- func (d *DefaultTcpProtocol) Decode(message []byte) (order uint32, messageType byte, code uint32, id uint64, route []byte, ...)
- func (d *DefaultTcpProtocol) Encode(order uint32, messageType byte, code uint32, id uint64, route []byte, ...) []byte
- func (d *DefaultTcpProtocol) HeadLen() int
- func (d *DefaultTcpProtocol) IsPing(messageType byte) bool
- func (d *DefaultTcpProtocol) IsPong(messageType byte) bool
- func (d *DefaultTcpProtocol) IsUnknown(messageType byte) bool
- func (d *DefaultTcpProtocol) PackPing() []byte
- func (d *DefaultTcpProtocol) PackPong() []byte
- func (d *DefaultTcpProtocol) Reader() func(n int, buf []byte, fn func(bytes []byte)) error
- type DefaultUdpProtocol
- func (d *DefaultUdpProtocol) Decode(message []byte) (order uint32, messageType byte, code uint32, id uint64, route []byte, ...)
- func (d *DefaultUdpProtocol) Encode(order uint32, messageType byte, code uint32, id uint64, route []byte, ...) []byte
- func (d *DefaultUdpProtocol) GetMessageType(message []byte) byte
- func (d *DefaultUdpProtocol) HeadLen() int
- func (d *DefaultUdpProtocol) IsClose(messageType byte) bool
- func (d *DefaultUdpProtocol) IsOpen(messageType byte) bool
- func (d *DefaultUdpProtocol) IsPing(messageType byte) bool
- func (d *DefaultUdpProtocol) IsPong(messageType byte) bool
- func (d *DefaultUdpProtocol) IsUnknown(messageType byte) bool
- func (d *DefaultUdpProtocol) PackClose() []byte
- func (d *DefaultUdpProtocol) PackOpen() []byte
- func (d *DefaultUdpProtocol) PackPing() []byte
- func (d *DefaultUdpProtocol) PackPong() []byte
- func (d *DefaultUdpProtocol) Reader() func(n int, buf []byte, fn func(bytes []byte)) error
- type DefaultWsProtocol
- func (d *DefaultWsProtocol) Decode(message []byte) (order uint32, messageType byte, code uint32, id uint64, route []byte, ...)
- func (d *DefaultWsProtocol) Encode(order uint32, messageType byte, code uint32, id uint64, route []byte, ...) []byte
- func (d *DefaultWsProtocol) HeadLen() int
- func (d *DefaultWsProtocol) IsPing(messageType byte) bool
- func (d *DefaultWsProtocol) IsPong(messageType byte) bool
- func (d *DefaultWsProtocol) IsUnknown(messageType byte) bool
- func (d *DefaultWsProtocol) PackPing() []byte
- func (d *DefaultWsProtocol) PackPong() []byte
- func (d *DefaultWsProtocol) Reader() func(n int, buf []byte, fn func(bytes []byte)) error
- type Protocol
- type UDPProtocol
Constants ¶
View Source
const ( Version byte = 'V' Unknown byte = 0 Text byte = 1 Bin byte = 2 Json byte = 3 ProtoBuf byte = 4 Ping byte = 9 Pong byte = 10 )
View Source
const ( Open byte = 5 Close byte = 6 )
Variables ¶
View Source
var CloseMessage = []byte{0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
View Source
var OpenMessage = []byte{0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
View Source
var PingMessage = []byte{0x0, 0x0, 0x9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
View Source
var PongMessage = []byte{0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
Functions ¶
This section is empty.
Types ¶
type DefaultTcpProtocol ¶
type DefaultTcpProtocol struct{}
func (*DefaultTcpProtocol) HeadLen ¶
func (d *DefaultTcpProtocol) HeadLen() int
func (*DefaultTcpProtocol) IsPing ¶
func (d *DefaultTcpProtocol) IsPing(messageType byte) bool
func (*DefaultTcpProtocol) IsPong ¶
func (d *DefaultTcpProtocol) IsPong(messageType byte) bool
func (*DefaultTcpProtocol) IsUnknown ¶
func (d *DefaultTcpProtocol) IsUnknown(messageType byte) bool
func (*DefaultTcpProtocol) PackPing ¶
func (d *DefaultTcpProtocol) PackPing() []byte
func (*DefaultTcpProtocol) PackPong ¶
func (d *DefaultTcpProtocol) PackPong() []byte
type DefaultUdpProtocol ¶
type DefaultUdpProtocol struct{}
func (*DefaultUdpProtocol) GetMessageType ¶
func (d *DefaultUdpProtocol) GetMessageType(message []byte) byte
func (*DefaultUdpProtocol) HeadLen ¶
func (d *DefaultUdpProtocol) HeadLen() int
func (*DefaultUdpProtocol) IsClose ¶
func (d *DefaultUdpProtocol) IsClose(messageType byte) bool
func (*DefaultUdpProtocol) IsOpen ¶
func (d *DefaultUdpProtocol) IsOpen(messageType byte) bool
func (*DefaultUdpProtocol) IsPing ¶
func (d *DefaultUdpProtocol) IsPing(messageType byte) bool
func (*DefaultUdpProtocol) IsPong ¶
func (d *DefaultUdpProtocol) IsPong(messageType byte) bool
func (*DefaultUdpProtocol) IsUnknown ¶
func (d *DefaultUdpProtocol) IsUnknown(messageType byte) bool
func (*DefaultUdpProtocol) PackClose ¶
func (d *DefaultUdpProtocol) PackClose() []byte
func (*DefaultUdpProtocol) PackOpen ¶
func (d *DefaultUdpProtocol) PackOpen() []byte
func (*DefaultUdpProtocol) PackPing ¶
func (d *DefaultUdpProtocol) PackPing() []byte
func (*DefaultUdpProtocol) PackPong ¶
func (d *DefaultUdpProtocol) PackPong() []byte
type DefaultWsProtocol ¶
type DefaultWsProtocol struct{}
func (*DefaultWsProtocol) HeadLen ¶
func (d *DefaultWsProtocol) HeadLen() int
func (*DefaultWsProtocol) IsPing ¶
func (d *DefaultWsProtocol) IsPing(messageType byte) bool
func (*DefaultWsProtocol) IsPong ¶
func (d *DefaultWsProtocol) IsPong(messageType byte) bool
func (*DefaultWsProtocol) IsUnknown ¶
func (d *DefaultWsProtocol) IsUnknown(messageType byte) bool
func (*DefaultWsProtocol) PackPing ¶
func (d *DefaultWsProtocol) PackPing() []byte
func (*DefaultWsProtocol) PackPong ¶
func (d *DefaultWsProtocol) PackPong() []byte
type Protocol ¶
type Protocol interface { Decode(message []byte) (order uint32, messageType byte, code uint32, id uint64, route []byte, body []byte) Encode(order uint32, messageType byte, code uint32, id uint64, route []byte, body []byte) []byte Reader() func(n int, buf []byte, fn func(bytes []byte)) error HeadLen() int PackPing() []byte PackPong() []byte IsPong(messageType byte) bool IsPing(messageType byte) bool IsUnknown(messageType byte) bool }
Click to show internal directories.
Click to hide internal directories.