.. _pingpong: ==================== Example: Ping Pong ==================== This example creates two different nodes, ``Ping`` and ``Pong``. The first node is executed with a fixed timing (see :ref:`Timed processing `) and sends a "Ping!" event over its output port. The second component listens to its input port and answers with a "Pong!". #. At first a Ping node is defined (lines 15-34). The node has one output port to send a string (line 30). In its main processing method it prints a "Ping!" to the console and sends the string over its output port (line 26). #. Then a Pong node is defined (lines 36-53). The node has one input port to receive a string (line 47). In its main processing method it prints a "Pong!" as answer. #. In the main function of this example we create a ping node and configure it to be timed (line 66, see :ref:`Timed `) and we configure the output port to send to the scope ``/ping`` (line 67). #. A pong node is created and configured to be triggered when an input arrives at its input port (line 71, see :ref:`Port-Triggered `) and we configure the input port to listen to the scope ``/ping``. #. To run the program we need to send a timing signal to the ping node. We create a :ref:`beat` and assign the ping node to it (lines 75-76). The pong node will be triggered by incoming input. *Note:* You can inspect the application with the :ref:`RSB Logger `, since the output scope of the Ping node is configured to also send over a remote transport. This should show an event with ``10Hz`` on the ``/ping`` scope. The input port of the pong node is configured to be only local, because otherwise the node would receive every event twice (over the local *and* the remote transport). .. literalinclude:: ../../examples/pingPong.cpp :language: c++ :emphasize-lines: 16-35,37-54,67-68,72,76-77 :linenos: