User Tools

Site Tools


devel:messaging

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

devel:messaging [2008/09/06 00:00] (current)
Line 1: Line 1:
 +====== Messaging ======
 +
 +RTS2 uses its own messaging system. Messages contains name of the originator, type (debug, info, warning, error) and message text, which is unformated string. Please note that this message subsystem is intended only to pass string messages. It was not invited to pass some structured infromation from one component to the other - for such tasks are commands.
 +
 +To send message from any RTS2 code, use:
 +
 +<code c++>
 +logStream (type) ​
 +  << 1234      // use it as stream, add others values if necessary
 +  << sendLog; ​ // send it
 +</​code>​
 +
 +where type is one of **MESSAGE_ERROR**,​ **MESSAGE_WARNING**,​ **MESSAGE_INFO**,​ **MESSAGE_DEBUG** (defined in [[http://​rts-2.svn.sf.net/​svnroot/​rts-2/​trunk/​rts-2/​include/​message.h|include/​message.h]]).
 +
 +So for example to send warning message, use:
 +
 +<code c++>
 +logStream (MESSAGE_WARNING) ​
 +   <<​ "This is warning message, component "
 +   <<​ 123454
 +   <<​ " failed with error "
 +   <<​ 12
 +   <<​ " (external intelligence not found)"​
 +   <<​ sendLog;
 +</​code>​
 +
 +To process messages coming from other connected devices over TCP/IP, hook on to public virtual function
 +
 +<code c++>
 +  virtual void message (Rts2Message & msg)
 +</​code>​
 +
 +Please see [[http://​rts-2.svn.sf.net/​svnroot/​rts-2/​trunk/​rts-2/​src/​utils/​rts2message.h|utils/​rts2message.h]] for operations allowed on message.
 +
 +To process messages which are generated inside application,​ you need to hook on virtual function sendMessage:​
 +
 +<code c++>
 +void Rts2Centrald::​sendMessage (messageType_t in_messageType,​ const char *in_messageString)
 +</​code>​
 +
 +You get message type and string to send. In order to send generated message to all connected devices, you need to call sendMessageAll. However, please note that usual infrastructure of RTS2 assumes that you send message only to centrald, and then centrald distributed message to log and to other components in the system. So you should not care about sending messages.
  
devel/messaging.txt ยท Last modified: 2008/09/06 00:00 (external edit)