protocol

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

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

func (d *DefaultTcpProtocol) Decode(message []byte) (order uint32, messageType byte, code uint32, id uint64, route []byte, body []byte)

func (*DefaultTcpProtocol) Encode

func (d *DefaultTcpProtocol) Encode(order uint32, messageType byte, code uint32, id uint64, route []byte, body []byte) []byte

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

func (*DefaultTcpProtocol) Reader

func (d *DefaultTcpProtocol) Reader() func(n int, buf []byte, fn func(bytes []byte)) error

type DefaultUdpProtocol

type DefaultUdpProtocol struct{}

func (*DefaultUdpProtocol) Decode

func (d *DefaultUdpProtocol) Decode(message []byte) (order uint32, messageType byte, code uint32, id uint64, route []byte, body []byte)

func (*DefaultUdpProtocol) Encode

func (d *DefaultUdpProtocol) Encode(order uint32, messageType byte, code uint32, id uint64, route []byte, body []byte) []byte

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

func (*DefaultUdpProtocol) Reader

func (d *DefaultUdpProtocol) Reader() func(n int, buf []byte, fn func(bytes []byte)) error

type DefaultWsProtocol

type DefaultWsProtocol struct{}

func (*DefaultWsProtocol) Decode

func (d *DefaultWsProtocol) Decode(message []byte) (order uint32, messageType byte, code uint32, id uint64, route []byte, body []byte)

func (*DefaultWsProtocol) Encode

func (d *DefaultWsProtocol) Encode(order uint32, messageType byte, code uint32, id uint64, route []byte, body []byte) []byte

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

func (*DefaultWsProtocol) Reader

func (d *DefaultWsProtocol) Reader() func(n int, buf []byte, fn func(bytes []byte)) error

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
}

type UDPProtocol

type UDPProtocol interface {
	Protocol
	GetMessageType([]byte) byte
	PackClose() []byte
	PackOpen() []byte
	IsClose(byte) bool
	IsOpen(byte) bool
}

Jump to

Keyboard shortcuts

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