Documentation ¶
Index ¶
- Constants
- func CalcMsgLenRequest(name []byte, encoding pld.Encoding, payload []byte) int
- func CalcMsgLenSignal(name []byte, encoding pld.Encoding, payload []byte) int
- func NewAcceptConfMessage(conf ServerConfiguration) ([]byte, error)
- func WriteMsgHeartbeat(writer io.WriteCloser) error
- func WriteMsgNamelessRequest(writer io.WriteCloser, reqType byte, identifier []byte, binaryPayload []byte) error
- func WriteMsgNotifySessionClosed(writer io.WriteCloser) error
- func WriteMsgNotifySessionCreated(writer io.WriteCloser, sessionInfo []byte) error
- func WriteMsgReply(writer io.WriteCloser, requestIdentifier []byte, payloadEncoding pld.Encoding, ...) error
- func WriteMsgReplyError(writer io.WriteCloser, requestIdent []byte, code, message []byte, ...) error
- func WriteMsgRequest(writer io.WriteCloser, identifier []byte, name []byte, ...) error
- func WriteMsgSignal(writer io.WriteCloser, name []byte, payloadEncoding pld.Encoding, ...) error
- func WriteMsgSpecialRequestReply(writer io.WriteCloser, reqType byte, reqIdent []byte) error
- type Buffer
- type Message
- func (msg *Message) Close()
- func (msg *Message) Identifier() [8]byte
- func (msg *Message) Name() []byte
- func (msg *Message) Payload() []byte
- func (msg *Message) PayloadEncoding() pld.Encoding
- func (msg *Message) PayloadUtf8() ([]byte, error)
- func (msg *Message) Read(reader io.Reader) (typeParsed bool, err error)
- func (msg *Message) ReadBytes(bytes []byte) (typeParsed bool, err error)
- func (msg *Message) RequiresReply() bool
- type Pool
- type ServerConfiguration
- type SyncPool
Constants ¶
const ( // MinLenSignal represents the minimum length // of binary/UTF8 encoded signal messages. // binary/UTF8 signal message structure: // 1. message type (1 byte) // 2. name length flag (1 byte) // 3. name (n bytes, optional if name length flag is 0) // 4. payload (n bytes, at least 1 byte) MinLenSignal = int(3) // MinLenSignalUtf16 represents the minimum length // of UTF16 encoded signal messages. // UTF16 signal message structure: // 1. message type (1 byte) // 2. name length flag (1 byte) // 3. name (n bytes, optional if name length flag is 0) // 4. header padding (1 byte, required if name length flag is odd) // 5. payload (n bytes, at least 2 bytes) MinLenSignalUtf16 = int(4) // MinLenRequest represents the minimum length // of binary/UTF8 encoded request messages. // binary/UTF8 request message structure: // 1. message type (1 byte) // 2. message id (8 bytes) // 3. name length flag (1 byte) // 4. name (from 0 to 255 bytes, optional if name length flag is 0) // 5. payload (n bytes, at least 1 byte or optional if name len > 0) MinLenRequest = int(11) // MinLenRequestUtf16 represents the minimum length // of UTF16 encoded request messages. // UTF16 request message structure: // 1. message type (1 byte) // 2. message id (8 bytes) // 3. name length flag (1 byte) // 4. name (n bytes, optional if name length flag is 0) // 5. header padding (1 byte, required if name length flag is odd) // 6. payload (n bytes, at least 2 bytes) MinLenRequestUtf16 = int(11) // MinLenReply represents the minimum length // of binary/UTF8 encoded reply messages. // binary/UTF8 reply message structure: // 1. message type (1 byte) // 2. message id (8 bytes) // 3. payload (n bytes, optional or at least 1 byte) MinLenReply = int(9) // MinLenReplyUtf16 represents the minimum length // of UTF16 encoded reply messages. // UTF16 reply message structure: // 1. message type (1 byte) // 2. message id (8 bytes) // 3. header padding (1 byte) // 4. payload (n bytes, optional or at least 2 bytes) MinLenReplyUtf16 = int(10) // MinLenReplyError represents the minimum length // of error reply messages. // Error reply message structure: // 1. message type (1 byte) // 2. message id (8 bytes) // 3. error code length flag (1 byte, cannot be 0) // 4. error code ( // from 1 to 255 bytes, // length must correspond to the length flag // ) // 5. error message (n bytes, UTF8 encoded, optional) MinLenReplyError = int(11) // MinLenRequestRestoreSession represents the minimum length // of session restoration request messages. // Session restoration request message structure: // 1. message type (1 byte) // 2. message id (8 bytes) // 3. session key (n bytes, 7-bit ASCII encoded, at least 1 byte) MinLenRequestRestoreSession = int(10) // MinLenDoCloseSession represents the minimum length // of session destruction request messages. // Session destruction request message structure: // 1. message type (1 byte) // 2. message id (8 bytes) MinLenDoCloseSession = int(9) // MinLenNotifySessionCreated represents the minimum length // of session creation notification messages. // Session creation notification message structure: // 1. message type (1 byte) // 2. session key (n bytes, 7-bit ASCII encoded, at least 1 byte) MinLenNotifySessionCreated = int(2) // MinLenNotifySessionClosed represents the minimum length // of session creation notification messages. // Session destruction notification message structure: // 1. message type (1 byte) MinLenNotifySessionClosed = int(1) // MinLenAcceptConf represents the minimum length // of an endpoint metadata message. // 1. message type (1 byte) // 2. major protocol version (1 byte) // 3. minor protocol version (1 byte) // 4. read timeout in milliseconds (4 byte) // 5. message buffer size in bytes (4 byte) // 6. sub-protocol name (0+ bytes) MinLenAcceptConf = int(11) )
const ( // MsgReplyError is a request reply sent only by the server and represents // an error-reply to a previously sent request MsgReplyError = byte(0) // MsgReplyShutdown is a request reply sent only by the server when a // request is received during server shutdown and can't therefore be // processed MsgReplyShutdown = byte(1) // MsgReplyInternalError is a request reply sent only by the server if an // unexpected internal error arose during the processing of a request MsgReplyInternalError = byte(2) // MsgReplySessionNotFound is a session restoration request reply sent only // by the server when the requested session was not found MsgReplySessionNotFound = byte(3) // MsgReplyMaxSessConnsReached is session restoration request reply sent // only by the server when the maximum number of concurrent connections for // a the requested session was reached MsgReplyMaxSessConnsReached = byte(4) // MsgReplySessionsDisabled is session restoration request reply sent only // by the server when sessions are disabled MsgReplySessionsDisabled = byte(5) // MsgNotifySessionCreated is a notification signal sent only by the server // to notify the client about the creation of a session MsgNotifySessionCreated = byte(21) // MsgNotifySessionClosed is a notification signal sent only by the server // to notify the client about the closure of the currently active session MsgNotifySessionClosed = byte(22) // MsgAcceptConf is a connection approval push-message sent only by the // server right after the handshake and includes the server configurations MsgAcceptConf = byte(23) // MsgRequestCloseSession is session closure command sent only by the client to // make the server close the currently active session MsgRequestCloseSession = byte(31) // MsgRequestRestoreSession is a session restoration request sent only by // the client MsgRequestRestoreSession = byte(32) // MsgHeartbeat is sent only by the client to acknowledge the server about // the activity of the connection to prevent it from shutting the connection // down on read timeout MsgHeartbeat = byte(33) // MsgSignalBinary represents a signal with binary payload MsgSignalBinary = byte(63) // MsgSignalUtf8 represents a signal with UTF8 encoded payload MsgSignalUtf8 = byte(64) // MsgSignalUtf16 represents a signal with UTF16 encoded payload MsgSignalUtf16 = byte(65) // MsgRequestBinary represents a request with binary payload MsgRequestBinary = byte(127) // MsgRequestUtf8 represents a request with a UTF8 encoded payload MsgRequestUtf8 = byte(128) // MsgRequestUtf16 represents a request with a UTF16 encoded payload MsgRequestUtf16 = byte(129) // MsgReplyBinary represents a reply with a binary payload MsgReplyBinary = byte(191) // MsgReplyUtf8 represents a reply with a UTF8 encoded payload MsgReplyUtf8 = byte(192) // MsgReplyUtf16 represents a reply with a UTF16 encoded payload MsgReplyUtf16 = byte(193) )
Variables ¶
This section is empty.
Functions ¶
func CalcMsgLenRequest ¶
CalcMsgLenRequest returns the size of a request message with the given name and payload
func CalcMsgLenSignal ¶
CalcMsgLenSignal returns the size of a signal message with the given name and payload
func NewAcceptConfMessage ¶
func NewAcceptConfMessage(conf ServerConfiguration) ([]byte, error)
NewAcceptConfMessage composes a server configuration message and writes it to the given buffer
func WriteMsgHeartbeat ¶
func WriteMsgHeartbeat(writer io.WriteCloser) error
WriteMsgHeartbeat writes a session closure notification message to the given writer closing it eventually
func WriteMsgNamelessRequest ¶
func WriteMsgNamelessRequest( writer io.WriteCloser, reqType byte, identifier []byte, binaryPayload []byte, ) error
WriteMsgNamelessRequest writes a nameless (initially without a name) request message to the given writer closing it eventually
func WriteMsgNotifySessionClosed ¶
func WriteMsgNotifySessionClosed(writer io.WriteCloser) error
WriteMsgNotifySessionClosed writes a session closure notification message to the given writer closing it eventually
func WriteMsgNotifySessionCreated ¶
func WriteMsgNotifySessionCreated( writer io.WriteCloser, sessionInfo []byte, ) error
WriteMsgNotifySessionCreated writes a session creation notification message to the given writer closing it eventually
func WriteMsgReply ¶
func WriteMsgReply( writer io.WriteCloser, requestIdentifier []byte, payloadEncoding pld.Encoding, payloadData []byte, ) error
WriteMsgReply writes a reply message to the given writer closing it eventually
func WriteMsgReplyError ¶
func WriteMsgReplyError( writer io.WriteCloser, requestIdent []byte, code, message []byte, safeMode bool, ) error
WriteMsgReplyError writes an error reply message to the given writer closing it eventually
func WriteMsgRequest ¶
func WriteMsgRequest( writer io.WriteCloser, identifier []byte, name []byte, payloadEncoding pld.Encoding, payloadData []byte, safeMode bool, ) error
WriteMsgRequest writes a named request message to the given writer closing it eventually
func WriteMsgSignal ¶
func WriteMsgSignal( writer io.WriteCloser, name []byte, payloadEncoding pld.Encoding, payloadData []byte, safeMode bool, ) error
WriteMsgSignal writes a named signal message to the given writer closing it eventually
func WriteMsgSpecialRequestReply ¶
func WriteMsgSpecialRequestReply( writer io.WriteCloser, reqType byte, reqIdent []byte, ) error
WriteMsgSpecialRequestReply writes a special request reply message to the given writer closing it eventually
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer represents a message buffer
func (*Buffer) Close ¶
func (buf *Buffer) Close()
Close resets the message buffer and puts it back into the original pool
type Message ¶
type Message struct { MsgBuffer Buffer MsgType byte MsgIdentifier [8]byte MsgIdentifierBytes []byte MsgName []byte MsgPayload pld.Payload // ServerConfiguration is only initialized for MsgAcceptConf type messages ServerConfiguration ServerConfiguration // contains filtered or unexported fields }
Message represents a non-thread-safe WebWire protocol message
func NewMessage ¶
NewMessage creates a new buffered message instance
func (*Message) Identifier ¶
Identifier implements the Message interface
func (*Message) PayloadEncoding ¶
PayloadEncoding implements the Message interface
func (*Message) PayloadUtf8 ¶
PayloadUtf8 implements the Message interface
func (*Message) RequiresReply ¶
RequiresReply returns true if a message of this type requires a reply, otherwise returns false.
type Pool ¶
type Pool interface { // Get fetches a message buffer from the pool which must be put back when // it's no longer needed Get() *Message }
Pool defines the message buffer pool interface
type ServerConfiguration ¶
type ServerConfiguration struct { MajorProtocolVersion byte MinorProtocolVersion byte SubProtocolName []byte ReadTimeout time.Duration MessageBufferSize uint32 }
ServerConfiguration represents the MsgAcceptConf payload data
type SyncPool ¶
type SyncPool struct {
// contains filtered or unexported fields
}
SyncPool represents a thread-safe messageBuffer pool
func NewSyncPool ¶
NewSyncPool initializes a new sync.Pool based message buffer pool instance
Source Files ¶
- buffer.go
- calcMsgLen.go
- message.go
- messageParts.go
- newAcceptConfMessage.go
- newMessage.go
- parse.go
- parseAcceptConf.go
- parseCloseSession.go
- parseErrorReply.go
- parseHeartbeat.go
- parseReply.go
- parseReplyUtf16.go
- parseRequest.go
- parseRequestUtf16.go
- parseRestoreSession.go
- parseSessionClosed.go
- parseSessionCreated.go
- parseSignal.go
- parseSignalUtf16.go
- parseSpecialReplyMessage.go
- pool.go
- read.go
- syncPool.go
- writeMsgErrorReply.go
- writeMsgHeartbeat.go
- writeMsgNamelessRequest.go
- writeMsgReply.go
- writeMsgRequest.go
- writeMsgSessionClosed.go
- writeMsgSessionCreated.go
- writeMsgSignal.go
- writeMsgSpecialRequestReply.go