Skip to content

Instantly share code, notes, and snippets.

@aozturk
Last active January 3, 2016 05:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aozturk/8417809 to your computer and use it in GitHub Desktop.
Save aozturk/8417809 to your computer and use it in GitHub Desktop.
void pub() {
// creates or gets the singleton AMS service
AMS::IService& service = AMS::IService::instance();
// enables exhaustive logging (i.e. message received/sent)
service.debug_mode();
// allows using global logger of AMS service
service.logger().information("publisher side running...");
// either creates a new domain or joins an existing one
// unique domain name and application name are provided
service.create_domain("ams_test", "Test_PUB");
// creates a publisher for the associated message
service.create_publisher<TestMsg>();
// starts the reactor for communication
service.reactor_start();
for (int i=0; i<100; ++i)
{
// prepares a message to send
TestMsg msg;
msg.value = i;
msg.name = "testing.";
// sends the message to all subscribers
service.send_message(msg);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment