Documentation
¶
Index ¶
Constants ¶
View Source
const (
// Header size in bytes (1 byte type + 4 bytes length).
HeaderSize = 5
)
Variables ¶
View Source
var (
ErrInvalidMessage = errors.New("invalid message")
)
Functions ¶
Types ¶
type BeginConnection ¶
type BeginConnection struct {
Subdomain string
}
func (*BeginConnection) Marshal ¶
func (b *BeginConnection) Marshal() *Message
Marshal converts a BeginConnection to a byte slice.
func (*BeginConnection) Unmarshal ¶
func (b *BeginConnection) Unmarshal(payload []byte)
Unmarshal converts a byte slice to a BeginConnection.
type CloseConnection ¶
type CloseConnection struct {
Reason string
}
func (*CloseConnection) Marshal ¶
func (c *CloseConnection) Marshal() *Message
func (*CloseConnection) Unmarshal ¶
func (c *CloseConnection) Unmarshal(payload []byte)
type ConnectionReady ¶
type ConnectionReady struct {
Subdomain string
}
func (*ConnectionReady) Marshal ¶
func (c *ConnectionReady) Marshal() *Message
Marshal converts a ConnectionReady to a byte slice.
func (*ConnectionReady) Unmarshal ¶
func (c *ConnectionReady) Unmarshal(payload []byte)
Unmarshal converts a byte slice to a ConnectionReady.
type ConnectionRegister ¶
type ConnectionRegister struct {
Subdomain string
Host string
Port uint32
Protocol Protocol
Token string
}
func (*ConnectionRegister) Marshal ¶
func (c *ConnectionRegister) Marshal() *Message
func (*ConnectionRegister) Unmarshal ¶
func (c *ConnectionRegister) Unmarshal(payload []byte)
type ConnectionRegisterResp ¶
func (*ConnectionRegisterResp) Marshal ¶
func (c *ConnectionRegisterResp) Marshal() *Message
func (*ConnectionRegisterResp) Unmarshal ¶
func (c *ConnectionRegisterResp) Unmarshal(payload []byte)
type EndConnection ¶
type EndConnection struct {
Subdomain string
}
func (*EndConnection) Marshal ¶
func (e *EndConnection) Marshal() *Message
Marshal converts an EndConnection to a byte slice.
func (*EndConnection) Unmarshal ¶
func (e *EndConnection) Unmarshal(payload []byte)
Unmarshal converts a byte slice to an EndConnection.
type ErrorMessage ¶
type ErrorMessage struct {
Message string
}
func NewErrorMessage ¶
func NewErrorMessage(message string) *ErrorMessage
func (*ErrorMessage) Marshal ¶
func (e *ErrorMessage) Marshal() *Message
func (*ErrorMessage) Unmarshal ¶
func (e *ErrorMessage) Unmarshal(payload []byte)
type Message ¶
type Message struct {
Type MessageType
Length uint32
Payload []byte
}
Message represents a protocol message.
func ReadMessage ¶
ReadMessage reads a message from the given reader.
type MessageType ¶
type MessageType int
const ( // Registration messages // These messages are used to register a connection with the server. MessageConnectionRegister MessageType = 1 MessageConnectionRegisterResp MessageType = 2 // Maintenance messages // These messages are used to maintain the connection with the server. MessageDisconnect MessageType = 3 MessageHeartbeat MessageType = 4 MessageError MessageType = 5 // Data messages // These messages are used to open and close streams of data. MessageBeginStream MessageType = 6 MessageEndStream MessageType = 7 MessageConnectionReady MessageType = 8 )
func (MessageType) String ¶
func (t MessageType) String() string
Click to show internal directories.
Click to hide internal directories.