Namespace: dmMessage
Language: C++
Type: Defold C++
File: message.h
Source: engine/dlib/src/dmsdk/dlib/message.h
Include: dmsdk/dlib/message.h
Api for sending messages
Type: ENUM Result enum
Members
RESULT_OK - = 0RESULT_SOCKET_EXISTS - = -1RESULT_SOCKET_NOT_FOUND - = -2RESULT_SOCKET_OUT_OF_RESOURCES - = -3RESULT_INVALID_SOCKET_NAME - = -4RESULT_MALFORMED_URL - = -5RESULT_NAME_OK_SOCKET_NOT_FOUND - = -6Type: STRUCT Helper struct for parsing a string of the form “socket:path#fragment”
Notes
Members
m_Socket (const char*) - The socketm_SocketSize (uint32_t) - The socket lengthm_Path (const char*) - The pathm_PathSize (uint32_t) - The path lengthm_Fragment (const char*) - The fragmentm_FragmentSize (uint32_t) - The fragment lengthType: STRUCT URL specifying a sender/receiver of messages
Notes
Type: TYPEDEF A callback for messages that needs cleanup after being dispatched. E.g. for freeing resources/memory.
Type: FUNCTION Get the message fragment
Parameters
url (dmMessage::URL) - urlReturns
fragment (dmhash_t)Type: FUNCTION Get the message path
Parameters
url (dmMessage::URL) - urlReturns
path (dmhash_t)Type: FUNCTION Get the message socket
Parameters
url (dmMessage::URL) - urlReturns
socket (dmMessage::HSocket)Type: FUNCTION Get socket name
Parameters
socket (dmMessage::HSocket) - SocketReturns
name (const char*) - socket name. 0 if it was not foundType: FUNCTION Get socket name hash
Parameters
socket (dmMessage::HSocket) - SocketReturns
name_hash (dmhash_t) - socket name hash. 0 if it was not foundType: TYPEDEF Socket handle
Type: FUNCTION Tests if a socket is valid (not deleted).
Parameters
socket (dmMessage::HSocket) - SocketReturns
result (bool) - if the socket is valid or notType: STRUCT
Type: STRUCT Message data desc used at dispatch callback. When a message is posted, the actual object is copied into the sockets internal buffer.
Members
m_Sender (dmMessage::URL) - Sender urim_Receiver (dmMessage::URL) - Receiver urim_Id (dmhash_t) - Unique id of messagem_UserData1 (uintptr_t) - User data pointerm_UserData2 (uintptr_t) - User data pointerm_Descriptor (uintptr_t) - User specified descriptor of the message datam_DataSize (uint32_t) - Size of message data in bytesm_Next (dmMessage::Message*) - Ptr to next message (or 0 if last)m_DestroyCallback (dmMessage::MessageDestroyCallback) - If set, will be called after each dispatchm_Data (uint8_t*) - PayloadType: FUNCTION Convert a string to a URL struct
Notes
Parameters
uri (const char*) - string of the format ][path[#fragment]out (dmMessage::StringUrl) - url in string format, must not be 0x0Returns
- - RESULT_OK on successType: FUNCTION Post an message to a socket
Notes
Parameters
sender (dmMessage::URL*) - The sender URL if the receiver wants to respond. 0x0 is acceptedreceiver (dmMessage::URL*) - The receiver URL, must not be 0x0message_id (dmhash_t) - Message iduser_data1 (uintptr_t) - User data that can be used when both the sender and receiver are knownuser_data2 (uintptr_t) - User data that can be used when both the sender and receiver are known.descriptor (uintptr_t) - User specified descriptor of the message datamessage_data (void*) - Message data referencemessage_data_size (uint32_t) - Message data size in bytesdestroy_callback (dmMessage::MessageDestroyCallback) - if set, will be called after each message dispatchReturns
RESULT_OK - if the message was postedType: FUNCTION Post a DDF message to a socket. A helper wrapper for Post()’ing a DDF message
Notes
Template Parameters
T - Must be a DDF typeParameters
message (T*) - Message data referencesender (dmMessage::URL*) - The sender URL if the receiver wants to respond. 0x0 is acceptedreceiver (dmMessage::URL*) - The receiver URL, must not be 0x0user_data1 (uintptr_t) - User data that can be used when both the sender and receiver are knownuser_data2 (uintptr_t) - User data that can be used when both the sender and receiver are known.destroy_callback (dmMessage::MessageDestroyCallback) - if set, will be called after each message dispatchReturns
RESULT_OK - if the message was postedExamples
// dmMessage::URL sender, receiver;
// dmGameObject::HInstance go;
dmGameSystemDDF::PlayAnimation msg;
msg.m_Id = animation_id;
msg.m_Offset = params.m_CursorStart;
msg.m_PlaybackRate = params.m_PlaybackRate;
dmMessage::Result result = dmMessage::Post(&msg, &sender, &receiver, (uintptr_t)go, 0, 0));
Type: FUNCTION Resets the given URL to default values.
Notes
Parameters
url (dmMessage::URL) - URL to resetType: FUNCTION Set the message fragment
Parameters
url (dmMessage::URL) - urlfragment (dmhash_t)Type: FUNCTION Set the message path
Parameters
url (dmMessage::URL) - urlpath (dmhash_t)Type: FUNCTION Set the socket
Parameters
url (dmMessage::URL) - urlsocket (dmMessage::HSocket)