Documentation
¶
Index ¶
Constants ¶
View Source
const ( // MessageTypePing sends a ping. After receiving a ping, the receiver // MUST respond with a pong message or the session will time out. MessageTypePing = "ping" // MessageTypePong is sent in response to a MessageTypePing. MessageTypePong = "pong" // MessageTypeOpen allocates a new peer-to-peer deviceconnect session. // The other peer can either respond with MessageTypeAccept or // MessageTypeError MessageTypeOpen = "open" // MessageTypeAccept is a successful response to an open request. MessageTypeAccept = "accept" // MessageTypeClose is sent when the session MUST close. All // communication on the session stop after receiving this message. MessageTypeClose = "close" // MessageTypeError is sent on a general protocol violation/error. // An error message MUST contain an Error object. If the object's // "close" field is set this message also closes the session. MessageTypeError = "error" )
View Source
const ProtocolVersion = 1
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Accept ¶
type Accept struct {
// Version is the accepted version used for this session.
Version int `msgpack:"version"`
// Protocols is a list of protocols the peer is willing to accept.
Protocols []ProtoType `msgpack:"protocols"`
}
Accept is the schema for the message type "accept" for a successful response to a ProtoMsg handshake.
type Error ¶
type Error struct {
// The error description, as in "Permission denied while opening a file"
Error string `msgpack:"err" json:"error"`
// Close determines whether the session closed as a result of this error.
Close bool `msgpack:"close" json:"close"`
// Code is the error code associated with the error. Values in the
// range 400-599 carry the same semantic meaning as the HTTP equivalent.
// Please allocate new error codes starting from 1000 for custom error codes.
Code int `msgpack:"code,omitempty" json:"code,omitempty"`
// MessageProto is the protocol of the message that caused the error.
MessageProto ProtoType `msgpack:"msgproto,omitempty" json:"message_protocol,omitempty"`
// Type of message that raised the error
MessageType string `msgpack:"msgtype,omitempty" json:"message_type,omitempty"`
// Message id is passed in the MsgProto Properties, and in case it is available and
// error occurs it is passed for reference in the Body of the error message
MessageID string `msgpack:"msgid,omitempty" json:"message_id,omitempty"`
}
The Error struct is passed in the Body of MessageTypeError.
type Open ¶
type Open struct {
// Versions is a list of versions the client is able to interpret.
Versions []int `msgpack:"versions"`
}
Open is the schema used for initiating a ProtoMsg handshake.
type ProtoHdr ¶
type ProtoHdr struct {
// Proto defines which protocol this message belongs
// to (required).
Proto ProtoType `msgpack:"proto"`
// MsgType is an optional content type header describing
// the protocol specific content type of the message.
MsgType string `msgpack:"typ,omitempty"`
// SessionID is used to identify one ProtoMsg stream for
// multiplexing multiple ProtoMsg sessions over the same connection.
SessionID string `msgpack:"sid,omitempty"`
// Properties provide a map of optional prototype specific
// properties (such as http headers or other meta-data).
Properties map[string]interface{} `msgpack:"props,omitempty"`
}
ProtoHdr provides the info about what the ProtoMsg contains and to which protocol the message should be routed.
type ProtoMsg ¶
type ProtoMsg struct {
// Header contains a protocol specific header with a single
// fixed ProtoType ("typ") field and optional hints for decoding
// the payload.
Header ProtoHdr `msgpack:"hdr"`
// Body contains the raw protocol data. The data contained in Body
// can be arbitrary and must be decoded according to the protocol
// defined in the header.
Body []byte `msgpack:"body,omitempty"`
}
ProtoMsg is a wrapper to messages communicated on bidirectional interfaces such as websockets to wrap data from other application protocols.
type ProtoType ¶
type ProtoType uint16
ProtoType defines how the ProtoMsg should be interpreted.
const ( // ProtoInvalid signifies an invalid (uninitialized) ProtoMsg. ProtoInvalid ProtoType = iota // ProtoTypeShell is used for communicating remote terminal session data. ProtoTypeShell // ProtoTypeFileTransfer is used for file transfer from/to the device. ProtoTypeFileTransfer // ProtoTypePortForward is used for port-forwarding connections to the device. ProtoTypePortForward // ProtoTypeMenderClient is used for communication with the Mender client. ProtoTypeMenderClient // ProtoTypeControl is a reserved proto type for session control messages. ProtoTypeControl ProtoType = 0xFFFF )
Click to show internal directories.
Click to hide internal directories.