Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Client Implementation

Callback Definition

C++

Code Block
languagecpp
titleMyCBImpl
linenumberstrue
collapsetrue
#include <AsyncC.h>

class MyCBImpl : public virtual POA_examples::MyCallback {
  public:
    MyCBImpl() {
        status=std::string("INIT");
    }
    virtual ~CBuLongImpl() {}
    void update(const char* value) {
        status = std::string(value);
    }
  public:
    std::string status;
};


Standalone Client

C++

Code Block
languagecpp
titleAsyncClient.cpp
linenumberstrue
collapsetrue
#include <maciSimpleClient.h>
#include <AsyncC.h>
#include <ACSErrTypeCommon.h>
#include <acsutilTimeStamp.h>
#include <MyCBImpl.h>

using namespace maci;
  
int main(int argc, char *argv[]) {
    SimpleClient client;
    examples::Async_var comp;
  
    if (client.init(argc,argv) == 0) {
        return -1;
    } else {
        client.login();
    }
  
    try {
        comp = client.getComponent<examples::Async>("ASYNC_CPP", 0, true);
    } catch(maciErrType::CannotGetComponentExImpl& _ex) {
        _ex.log();
        return -1;
    }
  
    MyCBImpl cb;
    examples::MyCallback_var cbObj = cb._this();
  
    ACS_SHORT_LOG((LM_INFO, "%s", cb.status));
    comp->delayAsync(8, cbObj.in());
  
    ACS_SHORT_LOG((LM_INFO, "%s", cb.status));
    sleep(5);
    ACS_SHORT_LOG((LM_INFO, "%s", cb.status));
    sleep(5);
  
    ACS_SHORT_LOG((LM_INFO, "%s", cb.status));
  
    try {
        client.releaseComponent("ASYNC_CPP");
    } catch(maciErrType::CannotReleaseComponentExImpl &_ex) {
        _ex.log();
        return -1;
    }
  
    client.logout();
  
    ACE_OS::sleep(3);
    return 0;
}


Component Client

C++

Code Block
languagecpp
titleAsyncClientImpl.h
linenumberstrue
collapsetrue
#ifndef _ASYNC_CLIENT_IMPL_H
#define _ASYNC_CLIENT_IMPL_H
 
#include <acscomponentImpl.h>
#include <AsyncS.h>
 
class AsyncClientImpl : public virtual acscomponent::ACSComponentImpl, public virtual POA_examples::AsyncClient
{
  public:
    AsyncClientImpl(const ACE_CString& name, maci::ContainerServices* containerServices);
    virtual ~AsyncClientImpl();
    void delay(ACS::uLong delay);
};
#endif

...