MessagePackage

class kanzi::connect::MessagePackage

Subclassed by GenericRPCReplyMessage, P2PLinkEstablishedMessage, SessionRunningMessage, SessionStartMessage, SessionStopMessage, SessionStoppedMessage, StreamNewBlobEvent, StreamReceiveEncoderParameterEvent, StreamReceiveStreamInfoEvent, StreamRemoveSubscriptionMethod, StreamRequestEncoderParameterMethod, StreamRequestStreamInfoMethod, StreamRestartEncoderMethod, StreamSetEncoderParameterMethod, StreamSetStreamContentMethod, StreamSubscribeBlobsMethod, StreamSubscriptionResultEvent

Public Types

enum AttributeType

Values:

enumerator ATTRIBUTE_VALUE_TYPE_UNKNOWN
enumerator ATTRIBUTE_VALUE_TYPE_INTEGER
enumerator ATTRIBUTE_VALUE_TYPE_FLOAT
enumerator ATTRIBUTE_VALUE_TYPE_BOOL
enumerator ATTRIBUTE_VALUE_TYPE_STRING
enumerator ATTRIBUTE_VALUE_TYPE_BINARY
enumerator ATTRIBUTE_VALUE_TYPE_PACKAGE
enumerator ATTRIBUTE_VALUE_TYPE_INTEGER64
enumerator ATTRIBUTE_VALUE_TYPE_DOUBLE
enumerator ATTRIBUTE_VALUE_TYPE_UNSIGNED_INTEGER
enumerator ATTRIBUTE_VALUE_TYPE_UNSIGNED_INTEGER64
enum CongestionControl

Values:

enumerator CONGESTION_CONTROL_NONE
enumerator CONGESTION_CONTROL_KEEP_LAST
enumerator CONGESTION_CONTROL_ARRAY_ATTRIBUTES
enum FixedAttributeKeys

Values:

enumerator ATTRIBUTE_KEY_UNKNOWN
enumerator ATTRIBUTE_KEY_NAME
enumerator ATTRIBUTE_KEY_EXPECTED_RETURNVALUE_TYPE
enumerator ATTRIBUTE_KEY_RETURNVALUE
enumerator ATTRIBUTE_KEY_ARGUMENT_COUNT
enumerator ATTRIBUTE_KEY_CLIENTID
enumerator ATTRIBUTE_KEY_SESSIONID
enumerator ATTRIBUTE_KEY_INTERFACEID
enumerator ATTRIBUTE_KEY_TO_JSON
enumerator ATTRIBUTE_KEY_MESSAGETYPE
enumerator ATTRIBUTE_KEY_VERSION
enumerator ATTRIBUTE_KEY_WRAPPED_MESSAGE
enumerator ATTRIBUTE_KEY_P2P_CLIENT_ID
enumerator ATTRIBUTE_KEY_REMOTESERVICE_CLIENT_PROTOCOL
enumerator ATTRIBUTE_KEY_REMOTESERVICE_CLIENT_ADDRESS
enumerator ATTRIBUTE_KEY_REMOTESERVICE_CLIENT_NAME
enumerator ATTRIBUTE_KEY_REMOTESERVICE_CLIENT_IDENTIFIER
enumerator ATTRIBUTE_KEY_P2P_SERVER_CLIENT_ID

Specifies the client identifier number as its seen by the server.

enumerator ATTRIBUTE_KEY_CONGESTION_CONTROL
enumerator ATTRIBUTE_KEY_ARGUMENT_1
enumerator ATTRIBUTE_KEY_ARGUMENT_101
enumerator ATTRIBUTE_KEY_LAST_RESERVED
enumerator ATTRIBUTE_KEY_RPC_CALL_HANDLE
enumerator ATTRIBUTE_KEY_RPC_STATUS
enumerator ATTRIBUTE_KEY_TYPE_DETAILS
enumerator ARRIBUTE_KEYS_BEGIN_EXTENDED_RANGE
enum MessageType

Values:

enumerator MESSAGETYPE_UNSPECIFIED
enumerator MESSAGETYPE_METHOD
enumerator MESSAGETYPE_ROUTED_METHOD
enumerator MESSAGETYPE_EVENT
enumerator MESSAGETYPE_ROUTED_EVENT
enumerator MESSAGETYPE_METHOD_RETURN
enumerator MESSAGETYPE_ROUTED_METHOD_RETURN
enumerator MESSAGETYPE_INVALID_ARGUMENTS_RESPONSE
enum SerializationFormat

Values:

enumerator SerializationFormatBinary

Binary format that preserves bandwidth, for low-latency purposes.

enumerator SerializationFormatJson

JSON format which is more verbose, mainly for REST.

enumerator SerializationFormatCompressedBinary

Public Functions

MessagePackage()
MessagePackage(MessagePackage &&package)
MessagePackage(const MessagePackage &package)
~MessagePackage()
bool addBinaryAttribute(int key, const string &value)

Add a binary string value to an attribute.

Return

True on success.

Parameters
  • key: Key identifying the attribute.

  • value: New value for the attribute.

bool addBinaryAttributeEx(int key, const unsigned char *blob, size_t size)

Add a binary data t to an attribute.

Parameters
  • key: the identifier for binary data

  • blob: the binary content

  • size: the size of the binary data.

bool addBoolAttribute(int key, bool value)

Add a boolean value to an attribute.

Return

True on success.

Parameters
  • key: Key identifying the attribute.

  • value: New value for the attribute.

bool addDoubleAttribute(int key, double value)

Add a double value to an attribute.

Return

True on success.

Parameters
  • key: Key identifying the attribute.

  • value: New value for the attribute.

bool addFloatAttribute(int key, float value)

Add a floating point value to an attribute.

Return

True on success.

Parameters
  • key: Key identifying the attribute.

  • value: New value for the attribute.

bool addInt64Attribute(int key, int64_t value)

Add 64bit integer value to an attribute.

Return

true on success.

Parameters
  • key: the key identifying the attribute.

  • value: the new value

bool addIntAttribute(int key, int value)

Add a integer value to an attribute.

Return

True on success.

Parameters
  • key: Key identifying the attribute.

  • value: New value for the attribute.

bool addPackageAttribute(int key, const MessagePackage &value)

Add a child message package to an attribute.

Return

True on success.

Parameters
  • key: Key identifying the attribute.

  • value: New value for the attribute.

bool addStringAttribute(int key, const string &value)

Add a string value to an attribute.

Return

True on success.

Parameters
  • key: Key identifying the attribute.

  • value: New value for the attribute.

bool addUInt64Attribute(int key, uint64_t value)

Add 64-bit integer value to an attribute.

Return

true on success.

Parameters
  • key: the key identifying the attribute.

  • value: the new value

bool addUIntAttribute(int key, unsigned int value)

Add a integer value to an attribute.

Return

True on success.

Parameters
  • key: Key identifying the attribute.

  • value: New value for the attribute.

unsigned int byteSize() const

Get binary size for the message.

Return

The byte size of package.

void clear()

Purge the contents of the package.

void eraseAttribute(int key)

Erase attribute array i.e.

clear all values for the given identifier.

Parameters
  • key: Key identifying the attribute.

string getAttributeKeyString(int key) const

Get attribute key string for an attribute.

See setAttributeKeyString().

Return

Attribute key string for the given attribute. Empty if the attribute is not found.

Parameters
  • key: Key identifying the attribute.

AttributeType getAttributeType(int key) const

Get the type of an attribute.

Return

The type of the attribute. See MessagePackage::AttributeType. MessagePackage::ATTRIBUTE_VALUE_TYPE_UNKNOWN if attribute was not found.

Parameters
  • key: Key identifying the attribute.

size_t getAttributeValuesCount(int key) const

Get the size of values array for an .

key Key of the attribute index.

Return

The count of the message attribute array items.

string getBinaryAttribute(int key, size_t index) const

Get the binary string value of an attribute.

Return

The integer value of the attribute. 0 if attribute was not found.

Parameters
  • key: Key identifying the attribute.

bool getBoolAttribute(int key, size_t index) const

Get the boolean value of an attribute.

Return

The integer value of the attribute. 0 if attribute was not found.

Parameters
  • key: Key identifying the attribute.

int getClientIdentifier() const

Get client identifier.

For convenience mostly, a client identifier can be accessed directly using getIntAttribute with key ATTRIBUTE_KEY_CLIENTID

Return

Identifier of the client bound to the message package.

double getDoubleAttribute(int key, size_t index) const

Get the double value of an attribute.

Return

The integer value of the attribute. 0 if attribute was not found.

Parameters
  • key: Key identifying the attribute.

float getFloatAttribute(int key, size_t index) const

Get the floating point value of an attribute.

Return

The integer value of the attribute. 0 if attribute was not found.

Parameters
  • key: Key identifying the attribute.

uint32_t getHandle() const
int64_t getInt64Attribute(int key, size_t index) const

Get the integer value of an attribute.

Return

The 64bit integer value of the attribute. 0 if attribute was not found.

Parameters
  • key: Key identifying the attribute.

  • index: Index of the attribute value. See getAttributeValuesCount().

int getIntAttribute(int key, size_t index) const

Get the integer value of an attribute.

Return

The integer value of the attribute. 0 if attribute was not found.

Parameters
  • key: Key identifying the attribute.

  • index: Index of the attribute value. See getAttributeValuesCount().

string getInterfaceIdentifier() const

Get interface identifier.

For convenience mostly, an interface identifier can be accessed directly using getIntAttribute with key ATTRIBUTE_KEY_INTERFACEID

Return

Identifier of the interface bound to the message package.

MessageType getMessageType() const

Get message type.

Return

The type of the message package. See MessagePackage::MessageType.

MessagePackage getPackageAttribute(int key, size_t index) const

Get the child message package of an attribute.

Return

The integer value of the attribute. 0 if attribute was not found.

Parameters
  • key: Key identifying the attribute.

bool getPackageAttributeTo(int key, size_t index, MessagePackage *to) const

Get the child message package of an attribute.

Return

true if success, false otherwise.

Parameters
  • key: Key identifying the attribute.

  • index: the index of the package in case multiple.

  • to: target package where to store the package from attribute.

int getSessionIdentifier() const

Get session identifier.

For convenience mostly, a session identifier can be accessed directly using getIntAttribute with key ATTRIBUTE_KEY_SESSIONID

Return

Identifier of the session bound to the message package.

string getSourceClientAddress() const

Retrieve configured client address.

Used with remote services.

Return

client address

int getSourceClientIdentifier() const

Retrieve source client identifier.

Used with remote services.

Return

client identifier.

string getSourceClientName() const

Retrieve configure client name.

Used with remote services.

Return

client name

string getSourceClientProtocol() const

Retrieve configured client protocol.

Used with remote services.

Return

client protocol

string getStringAttribute(int key, size_t index) const

Get the string value of an attribute.

Return

The integer value of the attribute. 0 if attribute was not found.

Parameters
  • key: Key identifying the attribute.

string getType() const

Get identity of this message.

ToDo: To be renamed to getName() or alike

Return

Type name for the message.

uint64_t getUInt64Attribute(int key, size_t index) const

Get the 64-bit unsigned integer value of an attribute.

Return

The 64bit integer value of the attribute. 0 if attribute was not found.

Parameters
  • key: Key identifying the attribute.

  • index: Index of the attribute value. See getAttributeValuesCount().

unsigned int getUIntAttribute(int key, size_t index) const

Get the unsigned integer value of an attribute.

Return

The integer value of the attribute. 0 if attribute was not found.

Parameters
  • key: Key identifying the attribute.

  • index: Index of the attribute value. See getAttributeValuesCount().

bool initialize(const string &buffer, bool isBinary)
MessagePackage &operator=(const MessagePackage &package)
string serializeAsString() const

Serialize message container to a string.

If attribute array contains boolean attribute ATTRIBUTE_KEY_TO_JSON with value true, the output string is to be produced as JSON, binary otherwise.

Return

Contents of the message container serialized as a string.

bool setAttributeKeyString(int key, const string &keyString)

Set attribute key string for an attribute.

Attribute setting and reading is based currently only the numeric value of the key so the key string is just additional information for the other peer.

Return

True on success.

Parameters
  • key: Key identifying the attribute.

  • keyString: The string to be attached to key.

bool setClientIdentifier(int identifier)

Set client identifier for the message package.

For convenience mostly, client identifier can be modified directly using setIntAttribute with key ATTRIBUTE_KEY_CLIENTID

Return

True on success.

Parameters
  • identifier: Identifier of a client.

bool setHandle(uint32_t handle)
bool setInterfaceIdentifier(string identifier)

Set interface identifier for the message package.

For convenience mostly, client identifier can be modified directly using setIntAttribute with key ATTRIBUTE_KEY_INTERFACEID

Return

True on success.

Parameters
  • identifier: Identifier of the client.

bool setMessageType(MessageType type)

Set message type.

Return

True on success.

Parameters
  • type: The type of the message package. See MessagePackage::MessageType.

bool setSessionIdentifier(int identifier)

Set session identifier for the message package.

For convenience mostly, a session identifier can be modified directly using setIntAttribute with key ATTRIBUTE_KEY_SESSIONID

Return

True on success.

Parameters
  • identifier: Identifier of a client.

bool setSourceClientAddress(const string &address)

Sets a client address.

Used in remote service communication to hold the address of the client that originally contacted server.

Return

true if ok

Parameters
  • address: the address (IP usually, but can be anything) to set.

bool setSourceClientIdentifier(int identifier)

Sets a client identifier.

Used in remote service communication to hold the client identifier at the server.

Return

true if ok

Parameters
  • identifier: the identifier number.

bool setSourceClientName(const string &name)

Sets a client name.

Used in remote service communication to hold the name of the client that contacted the server.

Return

true if ok

Parameters
  • name: the client name.

bool setSourceClientProtocol(const string &protocol)

Sets a client protocol.

Used in remote service communication to hold the protocol used when client contacted server.

Return

true if ok

Parameters
  • protocol: the communications protocol used.

bool setType(const string &type)

Set identity for this message.

ToDo: To be renamed to setName() or alike

Return

True on success.

Parameters
  • type: Type name for the message.

Public Members

unique_ptr<MessagePackageData> m_data