Server.cpp
1.02 KB
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
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//
#include <Ice/Ice.h>
#include <Printer.h>
#include "EvictorBase.h"
using namespace std;
using namespace Demo;
class PrinterI : public Printer
{
public:
virtual void printString(string s, const Ice::Current&) override;
void shutdown(const Ice::Current& c) override
{
cout << "Shutting down..." << endl;
c.adapter->getCommunicator()->shutdown();
}
};
void
PrinterI::printString(string s, const Ice::Current& c)
{
cout << c.id.name << ":" << s << endl;
}
int
main(int argc, char* argv[])
{
try
{
Ice::CommunicatorHolder ich(argc, argv);
auto adapter = ich->createObjectAdapterWithEndpoints("SimplePrinterAdapter", "default -p 10000");
auto defaultServant = make_shared<PrinterI>();
adapter->addDefaultServant(defaultServant,"");
adapter->activate();
ich->waitForShutdown();
}
catch(const std::exception& e)
{
cerr << e.what() << endl;
return 1;
}
return 0;
}