Skip to content

Instantly share code, notes, and snippets.

@aozturk
Last active January 3, 2016 05:39
Show Gist options
  • Select an option

  • Save aozturk/8417823 to your computer and use it in GitHub Desktop.

Select an option

Save aozturk/8417823 to your computer and use it in GitHub Desktop.

Revisions

  1. aozturk revised this gist Sep 14, 2014. 1 changed file with 20 additions and 20 deletions.
    40 changes: 20 additions & 20 deletions AMS_Subscriber.cpp
    Original file line number Diff line number Diff line change
    @@ -1,33 +1,33 @@
    // 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
    }
    }
    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();
    AMS::IService &service = AMS::IService::instance();

    service.debug_mode();
    service.logger().information("subscriber side running...");
    service.debug_mode();
    service.logger().information("subscriber side running...");

    // joins to the domain with unique application name
    service.create_domain("ams_test", "Test_SUB");
    // 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>();
    // creates a subscriber for the associated message
    service.create_subscriber<TestMsg>();

    // attaches handler to the subscriber
    TestMsgHandler handler;
    service.subscribe<TestMsg>(handler);
    // attaches handler to the subscriber
    TestMsgHandler handler;
    service.subscribe<TestMsg>(handler);

    // starts the reactor for communication
    service.reactor_start();
    // starts the reactor for communication
    service.reactor_start();

    // wait enough time here to receive messages sent by publisher
    // i.e. sleep
    // wait enough time here to receive messages sent by publisher
    // i.e. sleep
    }
  2. aozturk revised this gist Sep 14, 2014. 1 changed file with 21 additions and 21 deletions.
    42 changes: 21 additions & 21 deletions AMS_Subscriber.cpp
    Original file line number Diff line number Diff line change
    @@ -1,33 +1,33 @@
    // 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
    }
    }
    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();
    AMS::IService &service = AMS::IService::instance();

    service.debug_mode();
    service.logger().information("subscriber side running...");
    service.debug_mode();
    service.logger().information("subscriber side running...");

    // joins to the domain with unique application name
    service.create_domain("ams_test", "Test_SUB");
    // 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);
    // creates a subscriber for the associated message
    service.create_subscriber<TestMsg>();

    // starts the reactor for communication
    service.reactor_start();
    // attaches handler to the subscriber
    TestMsgHandler handler;
    service.subscribe<TestMsg>(handler);

    // wait enough time here to receive messages sent by publisher
    // i.e. sleep
    // starts the reactor for communication
    service.reactor_start();

    // wait enough time here to receive messages sent by publisher
    // i.e. sleep
    }
  3. aozturk revised this gist Jan 14, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion AMS_Subscriber.cpp
    Original file line number Diff line number Diff line change
    @@ -20,13 +20,14 @@ void 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 here to receive messages sent by pusblisher
    // wait enough time here to receive messages sent by publisher
    // i.e. sleep
    }
  4. aozturk created this gist Jan 14, 2014.
    32 changes: 32 additions & 0 deletions AMS_Subscriber.cpp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    // 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 here to receive messages sent by pusblisher
    // i.e. sleep
    }