summaryrefslogtreecommitdiff
path: root/cpp/test/Ice/echo/Server.cpp
blob: b701a9ab0554353be868e440a68be706cc912e30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// **********************************************************************
//
// Copyright (c) 2003-2018 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************

#include <Ice/Ice.h>
#include <TestHelper.h>
#include <BlobjectI.h>
#include <Test.h>

using namespace std;

class EchoI : public Test::Echo
{
public:

    EchoI(const BlobjectIPtr& blob) :
        _blob(blob)
    {
    }

    virtual void setConnection(const Ice::Current& current)
    {
        _blob->setConnection(current.con);
    }

    virtual void startBatch(const Ice::Current&)
    {
        _blob->startBatch();
    }

    virtual void flushBatch(const Ice::Current&)
    {
        _blob->flushBatch();
    }

    virtual void shutdown(const Ice::Current& current)
    {
        current.adapter->getCommunicator()->shutdown();
    }

private:

    BlobjectIPtr _blob;
};

class Server : public Test::TestHelper
{
public:

    void run(int, char**);
};

void
Server::run(int argc, char** argv)
{
    Ice::CommunicatorHolder communicator = initialize(argc, argv);
    communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint());
    Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
    BlobjectIPtr blob = ICE_MAKE_SHARED(BlobjectI);
    adapter->addDefaultServant(blob, "");
    adapter->add(ICE_MAKE_SHARED(EchoI, blob), Ice::stringToIdentity("__echo"));
    adapter->activate();
    serverReady();
    communicator->waitForShutdown();
}

DEFINE_TEST(Server)