180 | | Everytime the timer 'fires', ''eventFunction'' is called on a node (lines 110-125). In this example, the initiator sends a message to every node that has joined up to this point in time. To accomplish this, it iterates through all established links (line 119), builts a message for every link and finally sends the message using the Base Overlay in ''Ariba''. |
181 | | |
| 180 | Everytime the timer 'fires', ''eventFunction'' is called on a node (lines 110-125). In this example, the initiator sends a message to every node that has joined up to this point in time. To accomplish this, it iterates through all established links (line 119), builts a message for every link and finally sends the message using the Base Overlay in ''Ariba''. We will now take a short look at how such a message is composed in the ping pong example. |
| 181 | |
| 182 | {{{ |
| 183 | 01 #include "PingPongMessage.h" |
| 184 | 02 |
| 185 | 03 namespace ariba { |
| 186 | 04 namespace application { |
| 187 | 05 namespace pingpong { |
| 188 | 06 |
| 189 | 07 vsznDefault(PingPongMessage); |
| 190 | 08 |
| 191 | 09 PingPongMessage::PingPongMessage() : id(0) { |
| 192 | 10 } |
| 193 | 11 |
| 194 | 12 PingPongMessage::PingPongMessage(uint8_t _id) : id(_id) { |
| 195 | 13 } |
| 196 | 14 |
| 197 | 15 PingPongMessage::~PingPongMessage(){ |
| 198 | 16 } |
| 199 | 17 |
| 200 | 18 string PingPongMessage::info(){ |
| 201 | 19 return "ping pong message id " + ariba::utility::Helper::ultos(id); |
| 202 | 20 } |
| 203 | 21 |
| 204 | 22 uint8_t PingPongMessage::getid(){ |
| 205 | 23 return id; |
| 206 | 24 } |
| 207 | 25 |
| 208 | 26 }}} // namespace ariba, appplication, pingpong |
| 209 | }}} |
| 210 | |
| 211 | Lines 01-26 show the whole !PingPongMessage.cpp. One can see here that defining message types in Ariba is pretty simple. As the message in our case is empty and not of higher importantance, we refer the reader to the documentation for details. |
| 212 | |