Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrUnknownCompressType is returned when encountering an unknown compress type. ErrUnknownCompressType = errors.New("unknown compress type") // ErrInvalidDataLength is returned when the data length is invalid. ErrInvalidDataLength = errors.New("invalid data length") )
Functions ¶
func ParseProtocolIDsToStrings ¶
ParseProtocolIDsToStrings converts a ID slice to a string slice.
Types ¶
type CompressType ¶
type CompressType uint8
CompressType represents the type of compression used for payload.
const ( CompressTypeNone CompressType = iota // No compression CompressTypeGzip // Gzip compression )
type ID ¶
type ID string
ID is an identifier used to mark the module to which the network message belongs.
const ( // TestingProtocolID is a protocol ID for testing purposes. TestingProtocolID ID = "/_testing" )
func ParseStringsToProtocolIDs ¶
ParseStringsToProtocolIDs converts a string slice to a ID slice.
type PayloadPackage ¶
type PayloadPackage interface { ProtocolID() ID // Returns the protocol ID. Payload() []byte // Returns the payload data. Marshal() ([]byte, error) // Marshals the payload package into a byte slice. Unmarshal([]byte) error // Unmarshals the byte slice into the payload package. }
PayloadPackage represents a protocol payload package.
func NewPayloadPackage ¶
func NewPayloadPackage(protocol ID, payload []byte, compressType CompressType) PayloadPackage
type PayloadPkg ¶
type PayloadPkg struct {
// contains filtered or unexported fields
}
PayloadPkg represents a protocol payload package.
func (*PayloadPkg) Marshal ¶
func (p *PayloadPkg) Marshal() (bz []byte, err error)
Marshal marshals the payload package into a byte slice.
func (*PayloadPkg) Payload ¶
func (p *PayloadPkg) Payload() []byte
Payload returns the payload data of the payload package.
func (*PayloadPkg) ProtocolID ¶
func (p *PayloadPkg) ProtocolID() ID
ProtocolID returns the protocol ID of the payload package.
func (*PayloadPkg) Unmarshal ¶
func (p *PayloadPkg) Unmarshal(bz []byte) (err error)
Unmarshal unmarshals the byte slice into the payload package.
Click to show internal directories.
Click to hide internal directories.