protocol

package
v0.0.0-...-2fed64a Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2021 License: GPL-3.0, GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package protocol implements the client-daemon <-> push-server protocol.

Index

Constants

View Source
const (
	BrokenHostMismatch = "host-mismatch"
)

CONNBROKEN reasons

View Source
const ProtocolWireVersion = 0
View Source
const SystemChannelId = "0"

System channel id using a shortened hex-encoded form for the NIL UUID.

View Source
const (
	WarnUnauthorized = "unauthorized"
)

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.

func ReadWireFormatVersion

func ReadWireFormatVersion(conn net.Conn, exchangeTimeout time.Duration) (ver int, err error)

Types

type AckMsg

type AckMsg struct {
	Type string `json:"T"`
}

ACKnowledgement message

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

type ConnBrokenMsg struct {
	Type string `json:"T"`
	// reason
	Reason string
}

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

type ConnWarnMsg struct {
	Type string `json:"T"`
	// reason
	Reason string
}

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 PingPongMsg

type PingPongMsg struct {
	Type string `json:"T"`
}

PING/PONG messages

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

func NewProtocol0(conn net.Conn) Protocol

NewProtocol0 creates and initialises a protocol with wire format version 0.

type SetParamsMsg

type SetParamsMsg struct {
	Type      string `json:"T"`
	SetCookie string
}

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.

Jump to

Keyboard shortcuts

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