Documentation ¶
Overview ¶
Package protocol implements the client-daemon <-> push-server protocol.
Index ¶
- Constants
- func ExtractPayloads(notifications []Notification) []json.RawMessage
- func ReadWireFormatVersion(conn net.Conn, exchangeTimeout time.Duration) (ver int, err error)
- type AckMsg
- type BroadcastMsg
- type ConnAckMsg
- type ConnAckParams
- type ConnBrokenMsg
- type ConnWarnMsg
- type ConnectMsg
- type Notification
- type NotificationsMsg
- type OnewayMsg
- type PingPongMsg
- type Protocol
- type SetParamsMsg
- type SplittableMsg
Constants ¶
const (
BrokenHostMismatch = "host-mismatch"
)
CONNBROKEN reasons
const ProtocolWireVersion = 0
const SystemChannelId = "0"
System channel id using a shortened hex-encoded form for the NIL UUID.
const (
)CONNWARN reasons
Variables ¶
This section is empty.
Functions ¶
func ExtractPayloads ¶
func ExtractPayloads(notifications []Notification) []json.RawMessage
ExtractPayloads gets only the payloads out of a slice of notications.
Types ¶
type BroadcastMsg ¶
type BroadcastMsg struct { Type string `json:"T"` AppId string `json:",omitempty"` ChanId string TopLevel int64 Payloads []json.RawMessage // contains filtered or unexported fields }
BROADCAST messages
func (*BroadcastMsg) Reset ¶
func (b *BroadcastMsg) Reset()
Reset resets the splitting state if the message storage is to be reused and sets the proper Type.
func (*BroadcastMsg) Split ¶
func (m *BroadcastMsg) Split() bool
type ConnAckMsg ¶
type ConnAckMsg struct { Type string `json:"T"` Params ConnAckParams }
CONNACK message
type ConnAckParams ¶
type ConnAckParams struct { // ping interval formatted time.Duration PingInterval string }
ConnAckParams carries the connection parameters from the server on connection acknowledgement.
type ConnBrokenMsg ¶
CONNBROKEN message, server side is breaking the connection for reason.
func (*ConnBrokenMsg) OnewayContinue ¶
func (m *ConnBrokenMsg) OnewayContinue() bool
func (*ConnBrokenMsg) Split ¶
func (m *ConnBrokenMsg) Split() bool
type ConnWarnMsg ¶
CONNWARN message, server side is warning about partial functionality because reason.
func (*ConnWarnMsg) OnewayContinue ¶
func (m *ConnWarnMsg) OnewayContinue() bool
func (*ConnWarnMsg) Split ¶
func (m *ConnWarnMsg) Split() bool
type ConnectMsg ¶
type ConnectMsg struct { Type string `json:"T"` ClientVer string DeviceId string Authorization string Cookie string Info map[string]interface{} `json:",omitempty"` // platform etc... // maps channel ids (hex encoded UUIDs) to known client channel levels Levels map[string]int64 }
CONNECT message
type Notification ¶
type Notification struct { AppId string `json:"A"` MsgId string `json:"M"` // payload Payload json.RawMessage `json:"P"` }
A single unicast notification
type NotificationsMsg ¶
type NotificationsMsg struct { Type string `json:"T"` Notifications []Notification // contains filtered or unexported fields }
NOTIFICATIONS message
func (*NotificationsMsg) Reset ¶
func (m *NotificationsMsg) Reset()
Reset resets the splitting state if the message storage is to be reused and sets the proper Type.
func (*NotificationsMsg) Split ¶
func (m *NotificationsMsg) Split() bool
type OnewayMsg ¶
type OnewayMsg interface { SplittableMsg // continue session after the message? OnewayContinue() bool }
OnewayMsg are messages that are not to be followed by a response, after sending them the session either aborts or continues.
type Protocol ¶
type Protocol interface { SetDeadline(t time.Time) ReadMessage(msg interface{}) error WriteMessage(msg interface{}) error }
Protocol is a connection capable of writing and reading the wire format of protocol messages.
func NewProtocol0 ¶
NewProtocol0 creates and initialises a protocol with wire format version 0.
type SetParamsMsg ¶
SETPARAMS message
func (*SetParamsMsg) OnewayContinue ¶
func (m *SetParamsMsg) OnewayContinue() bool
func (*SetParamsMsg) Split ¶
func (m *SetParamsMsg) Split() bool
type SplittableMsg ¶
type SplittableMsg interface {
Split() (done bool)
}
SplittableMsg are messages that may require and are capable of splitting.