Structure for interprocess communications; can be sent either locally or remotely.
Attaches a buffer to the message.
Note: the Buffer recycles automatically along with the Message.
#include <cybiko.h> #define MSG_CHAT_STRING MSG_USER + 1 ... struct module_t main_module; struct Buffer message_buffer; char partner_name[9]; cyid_t partner_id; ... init_module( &main_module ); ... partner_id = select_game_partner( main_module.m_process, "Billiard", SGP_CYBIKO | SGP_HOT_SEAT, partner_name ); if( partner_id ) { ... struct Message* ptr_message = Message_new( sizeof( struct Message ) ); ptr_message->msgid = MSG_CHAT_STRING; Buffer_ctor( &message_buffer, 20, 10 ); Buffer_store_string( &message_buffer, "Hey, dude!", 0 ); Message_attach_buffer( ptr_message, &message_buffer ); Message_deliver( ptr_message, "Billiard", partner_id, 60*1000 ); } ...
Checks the delivery state.
#include <cybiko.h> #define MSG_TEST MSG_USER + 1 ... struct module_t main_module; char partner_name[9]; cyid_t partner_id; struct Message* ptr_message; delivery_t delivery_result; ... init_module( &main_module ); ... partner_id = select_game_partner( main_module.m_process, "Billiard", SGP_CYBIKO | SGP_HOT_SEAT, partner_name ); if( partner_id ) { ... ptr_message = Message_new( sizeof( struct Message ) ); ptr_message->msgid = MSG_TEST; // Sends message to "Billiard" application on the remote computer. Message_deliver( ptr_message, "Billiard", partner_id, 60*1000 ); } while(1) { cWinApp_pause( main_module.m_process, 250 ); delivery_result = Message_check_delivery( ptr_message ); if( delivery_result == DL_SUCCESS ) { TRACE( "Message was delivered successfully" ); break; } else if( ( delivery_result == DL_ABORT ) || ( delivery_result == DL_TIMEOUT ) ) { TRACE( "Message was not delivered successfully" ); break; } } ...
Makes the destination Message an exact copy of the source Message.
#include <cybiko.h> #define MSG_TEST MSG_USER + 1 ... struct Message* ptr_message = Message_new( sizeof( struct Message ) ); struct Message* ptr_message_repeat = Message_new( sizeof( struct Message ) ); ptr_message->msgid = MSG_TEST; ... Message_copy( ptr_message_repeat, ptr_message ); // Sends the message to the 'data_reciever' process which // is on the same device. Message_post( ptr_message, "data_reciever", get_own_id() ); // Repeats message. Message_post( ptr_message_repeat, "data_reciever", get_own_id() ); ...
Deletes a message.
#include <cybiko.h> #define MSG_TEST MSG_USER + 1 ... struct Message* ptr_message = Message_new( sizeof( struct Message ) ); ptr_message->msgid = MSG_TEST; // Sends the message to the 'data_reciever' process which // is on the same computer. Message_post( ptr_message, "data_reciever", get_own_id() ); ...
Delivers a message to a specified target, with delivery result notification.
#include <cybiko.h> #define MSG_TEST MSG_USER + 1 ... struct module_t main_module; struct Flag delivery_flag; char partner_name[9]; cyid_t partner_id; struct Message* ptr_message; ... init_module( &main_module ); ... partner_id = select_game_partner( main_module.m_process, "Billiard", SGP_CYBIKO | SGP_HOT_SEAT, partner_name ); if( partner_id ) { ... ptr_message = Message_new( sizeof( struct Message ) ); ptr_message->msgid = MSG_TEST; // Sends message to the "Billiard" application on the remote computer. Message_deliver( ptr_message, "Billiard", partner_id, 60*1000 ); } Flag_ctor(&delivery_flag, "MessageMutex", TRUE); if( Message_wait_delivery( ptr_message, &delivery_flag ) == DL_SUCCESS ) { TRACE( "Message was delivered successfully" ); } Flag_dtor(&delivery_flag, LEAVE_MEMORY); ...
Gets a pointer to the attached buffer.
Note, the Buffer created by the system when that receives the message will recycle automatically along with the Message.
#include <cybiko.h> #define MSG_CHAT_STRING MSG_USER + 1 ... struct module_t main_module; char sz_string_text[32]; ... init_module( &main_module ); ... struct Message* ptr_message = cWinApp_get_message( main_module.m_process, 0, 1, MSG_CHAT_STRING ); if( ptr_message->msgid == MSG_CHAT_STRING ) { if( Message_has_buffer( ptr_message ) ) { Buffer_load( Message_get_buffer( ptr_message ), sz_string_text, 0, 0 ); TRACE( "Message from the opponent: %s", sz_string_text ); } } ...
Returns a pointer to the message's KeyParam structure.
#include <cybiko.h> ... struct module_t main_module; struct Message* ptr_message; ... init_module( &main_module ); ... ptr_message = cWinApp_get_message( main_module.m_process, 0, 1, MSG_USER ); if( ptr_message->msgid == MSG_KEYDOWN ) { if( Message_get_key_param( ptr_message )->scancode == KEY_ESC ) { // Processes key 'Esc'. } } ...
Returns the 32-bit device ID (CyID) of the Message's sender.
Tests whether the Message has an attached buffer.
#include <cybiko.h> #define MSG_CHAT_STRING MSG_USER + 1 ... struct module_t main_module; char sz_string_text[32]; ... init_module( &main_module ); ... struct Message* ptr_message = cWinApp_get_message( main_module.m_process, 0, 1, MSG_CHAT_STRING ); if( ptr_message->msgid == MSG_CHAT_STRING ) { if( Message_has_buffer( ptr_message ) ) { Buffer_load( Message_get_buffer( ptr_message ), sz_string_text , 0, 0 ); TRACE( "Message from the opponent: %s", sz_string_text ); } } ...
Determines if the message has no specific address.
#include <cybiko.h> #define MSG_TASK_REQUEST MSG_USER + 1 ... struct module_t main_module; ... init_module( &main_module ); ... struct Message* ptr_message = cWinApp_get_message( main_module.m_process, 0, 1, MSG_TASK_REQUEST ); if( Message_is_broadcast( ptr_message ) ) { // Declines task. } else { // Accepts task. } ...
Returns a new Message from the system stores.
#include <cybiko.h> #define MSG_TEST MSG_USER + 1 ... struct Message* ptr_message = Message_new( sizeof( struct Message ) ); ptr_message->msgid = MSG_TEST; // Sends the message to the 'data_reciever' process which // is on the same computer. Message_post( ptr_message, "data_reciever", get_own_id() ); ...
Posts a message to a specified target.
#include <cybiko.h> #define MSG_TEST MSG_USER + 1 ... struct Message* ptr_message = Message_new( sizeof( struct Message ) ); ptr_message->msgid = MSG_TEST; // Sends the message to the 'data_reciever' process which // is on the same computer. Message_post( ptr_message, "data_reciever", get_own_id() ); ...
Posts a message to all Queues.
#include <cybiko.h> #define MSG_TEST MSG_USER + 1 ... struct Message* ptr_message = Message_new( sizeof( struct Message ) ); ptr_message->msgid = MSG_TEST; // Sends the message to all. This message will receive all // processes on the Cybiko computer. Message_post_all( ptr_message, QF_ALL ); ...
Waits until Message delivery is completed or flag is set.
#include <cybiko.h> #define MSG_TEST MSG_USER + 1 ... struct module_t main_module; struct Flag delivery_flag; char partner_name[9]; cyid_t partner_id; struct Message* ptr_message; ... init_module( &main_module ); ... partner_id = select_game_partner( main_module.m_process, "Billiard", SGP_CYBIKO | SGP_HOT_SEAT, partner_name ); if( partner_id ) { ... ptr_message = Message_new( sizeof( struct Message ) ); ptr_message->msgid = MSG_TEST; // Sends message to the "Billiard" application on the remote computer. Message_deliver( ptr_message, "Billiard", partner_id, 60*1000 ); } Flag_ctor(&delivery_flag, "MessageMutex", TRUE); if( Message_wait_delivery( ptr_message, &delivery_flag ) == DL_SUCCESS ) { TRACE( "Message was delivered successfully" ); } Flag_dtor(&delivery_flag, LEAVE_MEMORY); ...
Cy ID of the sender device.
Cy ID of the target device.
TRUE if the Message has been deleted from the queue.
The name of the target process.
ID of the Message.
Pointer to the next Message in the queue.
Additional parameters for the Message.