Sirikata
|
00001 // Copyright (c) 2011 Sirikata Authors. All rights reserved. 00002 // Use of this source code is governed by a BSD-style license that can 00003 // be found in the LICENSE file. 00004 00005 #ifndef _SIRIKATA_ENVIRONMENT_SPACE_MODULE_HPP_ 00006 #define _SIRIKATA_ENVIRONMENT_SPACE_MODULE_HPP_ 00007 00008 #include <sirikata/space/SpaceModule.hpp> 00009 #include <sirikata/space/ObjectSessionManager.hpp> 00010 00011 #include <json_spirit/value.h> 00012 00013 #include <sirikata/core/network/RecordSSTStream.hpp> 00014 00015 namespace Sirikata { 00016 00026 class Environment : public SpaceModule, public ObjectSessionListener { 00027 public: 00028 Environment(SpaceContext* ctx); 00029 00030 virtual void start(); 00031 virtual void stop(); 00032 00033 private: 00034 // ObjectSessionListener Interface 00035 virtual void newSession(ObjectSession* session); 00036 virtual void sessionClosed(ObjectSession *session); 00037 00038 void handleStream(int err, ODPSST::Stream::Ptr strm); 00039 void handleMessage(const ObjectReference& id, MemoryReference data); 00040 00041 void sendUpdate(const ObjectReference& id); 00042 00043 // The environment data 00044 json_spirit::Value mEnvironment; 00045 // Subscribers 00046 struct SubscriberInfo { 00047 ODPSST::Stream::Ptr stream; 00048 RecordSSTStream<ODPSST::Stream::Ptr> record_stream; 00049 }; 00050 typedef std::tr1::shared_ptr<SubscriberInfo> SubscriberInfoPtr; 00051 typedef std::tr1::unordered_map<ObjectReference, SubscriberInfoPtr, ObjectReference::Hasher> SubscriberMap; 00052 SubscriberMap mSubscribers; 00053 }; 00054 00055 } // namespace Sirikata 00056 00057 #endif //_SIRIKATA_ENVIRONMENT_SPACE_MODULE_HPP_