Messaging


Defines

#define MSG_AUTODELETE   0x80000000
#define MSG_MAX_TIMEOUT   0x0FFFFFFF
#define MSG_KEYMIN   1
#define MSG_KEYDOWN   1
#define MSG_KEYUP   2
#define MSG_CHARTYPED   3
#define MSG_TIMER   0x20
#define MSG_POWERDOWN   0x30
#define MSG_QUIT   0x31
#define MSG_PAINT   0x32
#define MSG_FILES   0x33
#define MSG_LOSTFOCUS   0x40
#define MSG_GOTFOCUS   0x41
#define MSG_LAUNCH   0x42
#define MSG_DEVICE   0x43
#define MSG_PING   0x44
#define MSG_SHUTUP   0x101A
#define MSG_USER   0x2000
#define DL_NONE   0
#define DL_INQUEUE   1
#define DL_WAIT   2
#define DL_ABORT   3
#define DL_TIMEOUT   4
#define DL_SUCCESS   5
#define MSG_USER_FOLK   0x1001

Typedefs

typedef long cyid_t
typedef int delivery_t

Enumerations

enum  qflag_t {
  QF_NONE = 0,
  QF_DEVICES = 1,
  QF_FILES = 2,
  QF_APPMASK = 0x1000,
  QF_ALL = 0xffff
}
enum  keymask_t {
  KEYMASK_SHIFT = 0x0001,
  KEYMASK_CTRL = 0x0002,
  KEYMASK_AUTOREPEAT = 0x0004
}

Functions

char howmany_around_desktop (void)
bool send_msg (char *app_name, int msgid, long d0, long d1, void *data, size_t size)
bool send_copy_msg (char *app_name, struct Message *msg)
bool send_remote_msg (cyid_t cyid, char *app_name, int msgid, long d0, long d1, void *data, size_t size)
bool send_remote_copy_msg (cyid_t cyid, char *app_name, struct Message *msg)
cyid_t get_own_id (void)


Compounds

     struct   BufferA dynamic memory buffer
     struct   KeyParamThe parameter holder for keyboard messages
     struct   MessageStructure for interprocess communications; can be sent either locally or remotely


Detailed Description

These functions and structures are used to send messages between applications, including those running on different Cybiko computers. You may also want to examine the Message and Buffer structures.


Define Documentation

#define DL_ABORT   3
 

Message delivery aborted by internal error or user request.

#define DL_INQUEUE   1
 

Message is in queue to deliver; please, don't delete the message while in this state.

#define DL_NONE   0
 

Message was created and possibly posted.

#define DL_SUCCESS   5
 

Message was delivered successfully.

#define DL_TIMEOUT   4
 

Message delivery finished by timeout.

#define DL_WAIT   2
 

Message is being delivered.

#define MSG_AUTODELETE   0x80000000
 

Message_deliver() flag, which deletes the message after it was delivered.

#define MSG_CHARTYPED   3
 

Sends the message to the focused program when the user releases a key.

#define MSG_DEVICE   0x43
 

Receiver sends the message when a device appears or disappears on the channel.

#define MSG_FILES   0x33
 

Lists changes in the file system.

#define MSG_GOTFOCUS   0x41
 

The process gets the message once it gets the focus.

#define MSG_KEYDOWN   1
 

Sends the message to the focused program when the user presses a key.

#define MSG_KEYMIN   1
 

Minimum ID of a keyboard message.

#define MSG_KEYUP   2
 

Sends the message to the focused program when the user releases a key.

#define MSG_LAUNCH   0x42
 

Sends the message to the Process you want to launch.

#define MSG_LOSTFOCUS   0x40
 

The Process gets the message when it loses focus.

#define MSG_MAX_TIMEOUT   0x0FFFFFFF
 

Message_deliver() maximum timeout.

#define MSG_PAINT   0x32
 

About repaint.

#define MSG_PING   0x44
 

Message is sent by the Receiver to ping the listener process.

#define MSG_POWERDOWN   0x30
 

Batteries are low, warn the user !

#define MSG_QUIT   0x31
 

Sends this message when the process should finish.

#define MSG_SHUTUP   0x101A
 

Process must be terminated.

#define MSG_TIMER   0x20
 

Sent when the pre-set timer counts down to 0.

#define MSG_USER   0x2000
 

Start of the user_defined message ID.

#define MSG_USER_FOLK   0x1001
 

ID of the message sent to the application when any device appears or disappears from the environment.


Typedef Documentation

typedef long cyid_t
 

Device's Cy ID.

typedef int delivery_t
 

Message delivery state.
Must be one of the following: DL_NONE, DL_INQUEUE, DL_WAIT, DL_ABORT, DL_TIMEOUT or DL_SUCCESS.

See also:
DL_NONE, DL_INQUEUE, DL_WAIT, DL_ABORT, DL_TIMEOUT, DL_SUCCESS.


Enumeration Type Documentation

enum keymask_t
 

Keyboard modifiers masks.

Enumeration values:
KEYMASK_SHIFT   Shift was pressed.
KEYMASK_CTRL   Control was pressed.
KEYMASK_AUTOREPEAT   It is autorepeat-generated message (not the first key down).

enum qflag_t
 

Enumeration of masks for local broadcast messages.

Enumeration values:
QF_NONE   Queue will get only messages for QF_NONE.
QF_DEVICES   Queue will get only messages for unit changes.
QF_FILES   Queue will get only messages for file system changes.
QF_APPMASK   First value for application masks.
QF_ALL   Mask for all MASKED queues.


Function Documentation

cyid_t get_own_id ( void )
 

Returns device's CyID.

Returns:
Device's CyID
       #include <cywin.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_receiver' process on the same device.
       Message_post( ptr_message, "data_receiver", get_own_id() );
       ...

char howmany_around_desktop ( void )
 

Returns the number of other users in the vicinity, with maximum activity.

Returns:
Number of Cybiko computers the finder detects
       #include <cybiko.h>
       ...
       TRACE("Active people: %d", finder.howmany_around);
       TRACE("Around desktop: %d", howmany_around_desktop());
       ...

bool send_copy_msg ( char * app_name,
struct Message * msg )
 

Sends a pre-written message to another application in the same Cybiko computer.

Parameters:
app_name   The name of the application to which the message is addressed
msg   Pointer to the pre-written message to be sent in Message structure
Returns:
1, if message was sent successfully, 0 otherwise
       #include <cybiko.h>
       ...
       #define MSG_REDRAW (MSG_USER + 1)
       ...
       struct module_t main_module;
       struct Message* ptr_message;
       long timeout;
       ...
       init_module( &main_module );
       ...
       //setting timeout for getting message
       timeout = 0;
       ptr_message = cWinApp_get_message( main_module.m_process,
                                          timeout,
                                          1,
                                          MSG_REDRAW );
       ...
       if( ptr_message && ptr_message->msgid == MSG_REDRAW )
       {
         //sending message to self
         char* app_name;
         app_name = cWinApp_get_name( main_module.m_process );
         send_copy_msg( app_name, ptr_message );
       }
       ...
See also:
cWinApp_get_message , cWinApp_get_name

bool send_msg ( char * app_name,
int msgid,
long d0,
long d1,
void * data,
size_t size )
 

Sends a message to another application in the same Cybiko computer.

Parameters:
app_name   The name of the application to which the message is addressed
msgid   Message identifier
d0   The message's 1st additional parameter (default value - 0)
d1   The message's 2nd additional parameter of message (default value - 0)
data   Pointer to message-related data (default value - 0)
size   Size of related data (default value - 0)
Returns:
1, if message was sent successfully, 0 otherwise
       #include <cybiko.h>                                          
       ...                                                          
       #define MSG_REDRAW (MSG_USER + 1)                            
       #define REDRAW_PARAM0  0x100                                 
       #define REDRAW_PARAM1  0x200                                 
       ...                                                          
       struct module_t main_module;                                 
       char* data = "sending string in message buffer";             
       char* app_name;                                              
       long param0, param1;                                         
       size_t size;                                                 
       ...                                                          
       init_module( &main_module );                                 
       ...                                                          
       //filling parameters                                         
       app_name = cWinApp_get_name( main_module.m_process );        
       param0 = REDRAW_PARAM0;                                      
       param1 = REDRAW_PARAM1;                                      
       size = strlen( data + 1 );                                   
       ...                                                          
       //sending message to self                                    
       send_msg( app_name, MSG_REDRAW, param0, param1, data, size );
       ...                                                          
See also:
Message_post, Message_has_buffer, Message_get_buffer

bool send_remote_copy_msg ( cyid_t cyid,
char * app_name,
struct Message * msg )
 

Sends pre-written message to another application in the same or other Cybiko computer.

Parameters:
cyid   CyID of the Cybiko computer to which the message is addressed
app_name   The name of the application to which the message is addressed
msg   Pointer to the pre-written message to be sent in Message structure
Returns:
1, if message was sent successfully, 0 otherwise
       #include <cybiko.h>
       ...
       #define MSG_USER_PING (MSG_USER + 1)
       ...
       struct module_t main_module;
       struct Message* ptr_message;
       cyid_t partner_id;
       ...
       init_module( &main_module );
       ...
       ptr_message = cWinApp_get_message( main_module.m_process, 0, 1, MSG_USER_PING );
       ...
       //getting message from partner
       if( ptr_message->msgid == MSG_USER_PING )
       {
         //filling parameters
         char* app_name = cWinApp_get_name( main_module.m_process );
         partner_id = ptr_message->cyid_from;
         ...
         //sending copy of the message back
         send_remote_copy_msg( partner_id, app_name, ptr_message );
       }
       ...
Message

bool send_remote_msg ( cyid_t cyid,
char * app_name,
int msgid,
long d0,
long d1,
void * data,
size_t size )
 

Sends message to another application in the same or another Cybiko computer.

Parameters:
cy_id   CyID of the Cybiko computer to which the message is addressed
app_name   The name of the application to which the message is addressed
msgid   Message identifier
d0   The message's 1st additional parameter (default value - 0)
d1   The message's 2nd additional parameter (default value - 0)
data   Pointer to message-related data (default value - 0)
size   Size of related data (default value - 0)
Returns:
1, if message was sent successfully, 0 otherwise
       #include <cybiko.h>
       ...
       #define MSG_USER_PING (MSG_USER + 1)
       #define PING_PARAM0   0x100
       #define PING_PARAM1   0x200
       ...
       struct module_t main_module;
       struct Message* ptr_message;
       char* data = "sending string in message buffer";
       cyid_t partner_id;
       long param0, param1;
       size_t size;
       ...
       init_module( &main_module );
       ...
       ptr_message = cWinApp_get_message( main_module.m_process, 0, 1, MSG_USER_PING );
       ...
       //getting message from partner
       if( ptr_message->msgid == MSG_USER_PING )
       {
         //filling parameters
         char* app_name = cWinApp_get_name( main_module.m_process );
         partner_id = ptr_message->cyid_from;
         param0 = PING_PARAM0;
         param1 = PING_PARAM1;
         size = strlen( data + 1 );
         ...
         //sending message to the same application on the partner's cybiko computer
         send_remote_msg( partner_id, app_name, MSG_USER_PING, param0, param1, data, size );
       }
       ...
See also:
Message , cWinApp_get_message