diff options
author | Matthew Newhook <matthew@zeroc.com> | 2005-02-01 17:42:12 +0000 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2005-02-01 17:42:12 +0000 |
commit | c34ec25e9755709f7959e17e5303be04af849fca (patch) | |
tree | c24bf753ca359c81ce100e8f4ecb7fa1d5092185 /cpp/demo/Glacier2/chat/Server.cpp | |
parent | Docu fixes (diff) | |
download | ice-c34ec25e9755709f7959e17e5303be04af849fca.tar.bz2 ice-c34ec25e9755709f7959e17e5303be04af849fca.tar.xz ice-c34ec25e9755709f7959e17e5303be04af849fca.zip |
chat demo.
Diffstat (limited to 'cpp/demo/Glacier2/chat/Server.cpp')
-rwxr-xr-x | cpp/demo/Glacier2/chat/Server.cpp | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/cpp/demo/Glacier2/chat/Server.cpp b/cpp/demo/Glacier2/chat/Server.cpp new file mode 100755 index 00000000000..6a15f47b67d --- /dev/null +++ b/cpp/demo/Glacier2/chat/Server.cpp @@ -0,0 +1,73 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2004 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/Application.h> +#include <Glacier2/PermissionsVerifier.h> + +#include <ChatSessionI.h> + +using namespace std; +using namespace Ice; +using namespace Demo; + +class DummyPermissionsVerifierI : public Glacier2::PermissionsVerifier +{ +public: + + virtual bool + checkPermissions(const string& userId, const string& passwd, string&, const Ice::Current&) const + { + return true; + } +}; + +class ChatRoomSessionManagerI : public Glacier2::SessionManager +{ +public: + + ChatRoomSessionManagerI() : + _members(new ChatRoomMembers()) + { + } + + virtual Glacier2::SessionPrx + create(const string& userId, const ::Ice::Current& current) + { + return Glacier2::SessionPrx::uncheckedCast(current.adapter->addWithUUID(new ChatSessionI(_members, userId))); + } + +private: + + ChatRoomMembersPtr _members; +}; + +class ChatSessionServer : public Application +{ +public: + + virtual int + run(int, char*[]) + { + Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("ChatServer"); + + adapter->add(new DummyPermissionsVerifierI, Ice::stringToIdentity("verifier")); + adapter->add(new ChatRoomSessionManagerI, Ice::stringToIdentity("ChatRoomSessionManager")); + adapter->activate(); + communicator()->waitForShutdown(); + + return EXIT_SUCCESS; + } +}; + +int +main(int argc, char* argv[]) +{ + ChatSessionServer app; + return app.main(argc, argv, "config.server"); +} |