#include <Ice/Ice.h>
|
|
#include <MWSessionManagerI.h>
|
|
// #include <PollingChatSessionFactoryI.h>
|
|
|
|
using namespace std;
|
|
|
|
class MWServer : public Ice::Service
|
|
{
|
|
public:
|
|
|
|
virtual bool start(int argc, char* argv[], int&) override;
|
|
virtual bool stop() override;
|
|
|
|
private:
|
|
|
|
shared_ptr<Ice::ObjectAdapter> _adapter;
|
|
};
|
|
|
|
bool
|
|
MWServer::start(int, char*[], int& status)
|
|
{
|
|
// int timeout = communicator()->getProperties()->getPropertyAsIntWithDefault("PollingChatSessionTimeout", 10);
|
|
bool traceEnabled = communicator()->getProperties()->getPropertyAsIntWithDefault("Server.Trace", 0) != 0;
|
|
auto logger = communicator()->getLogger();
|
|
|
|
try
|
|
{
|
|
_adapter = communicator()->createObjectAdapter("MWServer");
|
|
|
|
auto mwmap = make_shared<MWMap>(traceEnabled, logger);
|
|
if(traceEnabled)
|
|
{
|
|
Ice::Trace out(logger, "info");
|
|
out << "MW room created ok.";
|
|
}
|
|
_adapter->add(make_shared<MWSessionManagerI>(mwmap, traceEnabled, logger),
|
|
Ice::stringToIdentity("MWSessionManager"));
|
|
|
|
if(traceEnabled)
|
|
{
|
|
Ice::Trace out(logger, "info");
|
|
out << "MW session manager created ok.";
|
|
}
|
|
// _adapter->add(make_shared<PollingChatSessionFactoryI>(chatRoom, timeout, traceEnabled, logger),
|
|
// Ice::stringToIdentity("PollingChatSessionFactory"));
|
|
|
|
// if(traceEnabled)
|
|
// {
|
|
// Ice::Trace out(logger, "info");
|
|
// out << "Polling chat session factory created ok.";
|
|
// }
|
|
|
|
_adapter->activate();
|
|
if(traceEnabled)
|
|
{
|
|
Ice::Trace out(logger, "info");
|
|
out << "MW server started ok.";
|
|
}
|
|
}
|
|
catch(const Ice::LocalException&)
|
|
{
|
|
status = 1;
|
|
throw;
|
|
}
|
|
status = 0;
|
|
return true;
|
|
}
|
|
|
|
bool
|
|
MWServer::stop()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
int
|
|
main(int argc, char* argv[])
|
|
{
|
|
#ifdef ICE_STATIC_LIBS
|
|
Ice::registerIceSSL();
|
|
Ice::registerIceWS();
|
|
#endif
|
|
MWServer app;
|
|
return app.main(argc, argv);
|
|
}
|