This example shows how to set up a match handler for use with a forwarding table. In this example, the forwarding table processes messages of type text_message
delegating the output function to an object of type simple_handler
. simple_handler
puts out each message to a set of output streams associated with the matching interfaces. The handler also implements a cut-off mechanism that limits the number of output streams that a message is copied to. In this particular example, this limit is set to 5. Notice that the handler is initialized with a reference to message that is of the actual message type. This allows the handler to use specific access methods for its output function. In this example, the handler uses the get_text()
method to obtain the output text from the message object.