Last active
January 3, 2016 05:39
-
-
Save aozturk/8417823 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// defines a handler class for the message first | |
class TestMsgHandler : public AMS::IHandler { | |
public: | |
virtual void handle(AMS::IMsgObj *baseMsg) { | |
TestMsg *msg = dynamic_cast<TestMsg *>(baseMsg); | |
if (msg != 0) { | |
// process message here | |
} | |
} | |
}; | |
void sub() { | |
AMS::IService &service = AMS::IService::instance(); | |
service.debug_mode(); | |
service.logger().information("subscriber side running..."); | |
// joins to the domain with unique application name | |
service.create_domain("ams_test", "Test_SUB"); | |
// creates a subscriber for the associated message | |
service.create_subscriber<TestMsg>(); | |
// attaches handler to the subscriber | |
TestMsgHandler handler; | |
service.subscribe<TestMsg>(handler); | |
// starts the reactor for communication | |
service.reactor_start(); | |
// wait enough time here to receive messages sent by publisher | |
// i.e. sleep | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment