Changeset 7284 for code/trunk/src/libraries/network
- Timestamp:
- Aug 31, 2010, 3:37:40 AM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/network/Client.cc
r7163 r7284 45 45 #include "util/Clock.h" 46 46 #include "util/Debug.h" 47 #include "util/ScopedSingletonManager.h" 47 48 #include "synchronisable/Synchronisable.h" 48 49 #include "packet/Chat.h" … … 52 53 #include "core/CommandLineParser.h" 53 54 #include "core/Game.h" 54 #include "core/ScopedSingletonManager.h"55 55 56 56 namespace orxonox … … 107 107 return ClientConnection::closeConnection(); 108 108 } 109 109 110 110 void Client::setDestination(const std::string& serverAddress, unsigned int port) 111 111 { -
code/trunk/src/libraries/network/ClientConnection.cc
r6417 r7284 149 149 uint32_t ClientConnection::getRTT() 150 150 { 151 assert(server_); 152 return server_->roundTripTime; 151 if (server_) 152 return server_->roundTripTime; 153 else 154 return 0; 153 155 } 154 156 -
code/trunk/src/libraries/network/GamestateManager.cc
r7163 r7284 47 47 48 48 #include "util/Debug.h" 49 #include "core/Executor.h"50 49 #include "core/ThreadPool.h" 50 #include "core/command/Executor.h" 51 51 #include "ClientInformation.h" 52 52 #include "packet/Acknowledgement.h" -
code/trunk/src/libraries/network/Host.cc
r7163 r7284 32 32 #include <string> 33 33 34 #include "core/ConsoleCommand.h"35 34 #include "core/ObjectList.h" 35 #include "core/command/ConsoleCommand.h" 36 36 #include "ChatListener.h" 37 37 38 38 namespace orxonox { 39 39 40 SetConsoleCommandShortcut(Host, Chat); 40 static const std::string __CC_printRTT_name = "printRTT"; 41 42 SetConsoleCommand("chat", &Host::Chat); 43 SetConsoleCommand(__CC_printRTT_name, &Host::printRTT); 41 44 42 45 // Host* Host::instance_=0; … … 52 55 // assert(instance_==0); 53 56 instances_s.push_back(this); 54 this->printRTTCC_ = createConsoleCommand( createFunctor(&Host::printRTT, this), "printRTT" ); 55 CommandExecutor::addConsoleCommandShortcut( this->printRTTCC_ ); 57 ModifyConsoleCommand(__CC_printRTT_name).setObject(this); 56 58 this->bIsActive_ = false; 57 59 } … … 65 67 assert( std::find( instances_s.begin(), instances_s.end(), this )!=instances_s.end() ); 66 68 instances_s.erase(std::find( instances_s.begin(), instances_s.end(), this )); 67 if( this->printRTTCC_ ) 68 delete this->printRTTCC_; 69 ModifyConsoleCommand(__CC_printRTT_name).setObject(0); 69 70 } 70 71 … … 89 90 } 90 91 91 boolHost::Chat(const std::string& message)92 void Host::Chat(const std::string& message) 92 93 { 93 94 if(instances_s.size()==0) … … 95 96 for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it) 96 97 it->incomingChat(message, 0); 97 return true;98 // return true; 98 99 } 99 100 else … … 108 109 } 109 110 } 110 return result;111 // return result; 111 112 } 112 113 } … … 139 140 for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it) 140 141 it->incomingChat(message, playerID); 141 142 142 143 bool result = true; 143 144 for( std::vector<Host*>::iterator it = instances_s.begin(); it!=instances_s.end(); ++it ) -
code/trunk/src/libraries/network/Host.h
r7163 r7284 79 79 static void setShipID(unsigned int id){ shipID_s = id; } 80 80 static bool isServer(); 81 static boolChat(const std::string& message);81 static void Chat(const std::string& message); 82 82 static bool Broadcast(const std::string& message); 83 83 static bool incomingChat(const std::string& message, unsigned int playerID); … … 85 85 bool isActive(){ return bIsActive_; } 86 86 private: 87 ConsoleCommand* printRTTCC_;88 87 static uint32_t clientID_s; 89 88 static uint32_t shipID_s; -
code/trunk/src/libraries/network/LANDiscovery.cc
r7163 r7284 32 32 #include <cstring> 33 33 34 #include "util/ScopedSingletonManager.h" 34 35 #include "core/CoreIncludes.h" 35 #include "core/ScopedSingletonManager.h"36 36 37 37 38 38 namespace orxonox 39 { 39 { 40 40 ManageScopedSingleton(LANDiscovery, ScopeID::Root, true); 41 41 42 42 LANDiscovery::LANDiscovery() 43 43 { … … 49 49 enet_host_destroy(this->host_); 50 50 } 51 51 52 52 void LANDiscovery::discover() 53 53 { … … 56 56 enet_address_set_host(&address, "255.255.255.255"); 57 57 address.port = LAN_DISCOVERY_PORT; 58 58 59 59 ENetPeer* peer; 60 60 peer = enet_host_connect(this->host_, &address, 0); 61 61 62 62 ENetEvent event; 63 63 while( enet_host_service(this->host_, &event, 1000 ) ) … … 93 93 } 94 94 } 95 95 96 96 std::string LANDiscovery::getServerListItemName(unsigned int index) 97 97 { … … 101 101 return this->servers_[index].getServerName(); 102 102 } 103 103 104 104 std::string LANDiscovery::getServerListItemIP(unsigned int index) 105 105 { … … 109 109 return this->servers_[index].getServerIP(); 110 110 } 111 112 111 112 113 113 } // namespace orxonox -
code/trunk/src/libraries/network/NetworkFunction.cc
r6417 r7284 68 68 69 69 70 NetworkFunctionStatic::NetworkFunctionStatic( FunctorStatic*functor, const std::string& name, const NetworkFunctionPointer& p):70 NetworkFunctionStatic::NetworkFunctionStatic(const FunctorStaticPtr& functor, const std::string& name, const NetworkFunctionPointer& p): 71 71 NetworkFunctionBase(name) 72 72 { … … 76 76 NetworkFunctionStatic::getFunctorMap()[p] = this; 77 77 NetworkFunctionStatic::getIdMap()[ this->getNetworkID() ] = this; 78 }79 80 NetworkFunctionStatic::~NetworkFunctionStatic()81 {82 delete this->functor_;83 78 } 84 79 -
code/trunk/src/libraries/network/NetworkFunction.h
r6417 r7284 39 39 #include <boost/static_assert.hpp> 40 40 41 #include "core/Functor.h"42 41 #include "core/Identifier.h" 42 #include "core/command/Functor.h" 43 43 #include "FunctionCallManager.h" 44 44 #include "synchronisable/Synchronisable.h" … … 102 102 class _NetworkExport NetworkFunctionStatic: public NetworkFunctionBase { 103 103 public: 104 NetworkFunctionStatic(FunctorStatic* functor, const std::string& name, const NetworkFunctionPointer& p); 105 ~NetworkFunctionStatic(); 104 NetworkFunctionStatic(const FunctorStaticPtr& functor, const std::string& name, const NetworkFunctionPointer& p); 106 105 107 106 inline void call(){ (*this->functor_)(); } … … 124 123 static std::map<NetworkFunctionPointer, NetworkFunctionStatic*>& getFunctorMap(); 125 124 static std::map<uint32_t, NetworkFunctionStatic*>& getIdMap(); 126 FunctorStatic *functor_;125 FunctorStaticPtr functor_; 127 126 128 127 }; … … 155 154 template <class T> class NetworkMemberFunction: public NetworkMemberFunctionBase { 156 155 public: 157 NetworkMemberFunction(FunctorMember<T>* functor, const std::string& name, const NetworkFunctionPointer& p); 158 ~NetworkMemberFunction(); 156 NetworkMemberFunction(const FunctorMemberPtr<T>& functor, const std::string& name, const NetworkFunctionPointer& p); 159 157 160 158 inline void call(uint32_t objectID) … … 190 188 191 189 private: 192 FunctorMember <T>*functor_;193 }; 194 195 template <class T> NetworkMemberFunction<T>::NetworkMemberFunction( FunctorMember<T>*functor, const std::string& name, const NetworkFunctionPointer& p):190 FunctorMemberPtr<T> functor_; 191 }; 192 193 template <class T> NetworkMemberFunction<T>::NetworkMemberFunction(const FunctorMemberPtr<T>& functor, const std::string& name, const NetworkFunctionPointer& p): 196 194 NetworkMemberFunctionBase(name, p), functor_(functor) 197 195 { 198 }199 template <class T> NetworkMemberFunction<T>::~NetworkMemberFunction()200 {201 delete this->functor_;202 196 } 203 197 -
code/trunk/src/libraries/network/Server.cc
r7163 r7284 49 49 #include "util/Debug.h" 50 50 #include "core/ObjectList.h" 51 #include "core/ Executor.h"51 #include "core/command/Executor.h" 52 52 #include "packet/Chat.h" 53 53 #include "packet/ClassID.h" -
code/trunk/src/libraries/network/synchronisable/Serialise.h
r7266 r7284 42 42 #include "core/CorePrereqs.h" 43 43 #include "core/CoreIncludes.h" 44 #include "core/SmartPtr.h" 44 #include "core/BaseObject.h" // remove this if circular dependencies in BaseObject/SmartPtr are fixed 45 //#include "core/SmartPtr.h" 45 46 46 47 namespace orxonox{ 47 48 48 49 // These functions implement loading / saving / etc. for pointer types 49 50 50 51 /** @brief returns the size of the objectID needed to synchronise the pointer */ 51 52 template <class T> inline uint32_t returnSize( T*& variable ) … … 53 54 return sizeof(uint32_t); 54 55 } 55 56 56 57 /** @brief reads the objectID of a pointer out of the bytestream and increases the mem pointer */ 57 58 template <class T> inline void loadAndIncrease( T*& variable, uint8_t*& mem ) … … 60 61 mem += returnSize( variable ); 61 62 } 62 63 63 64 /** @brief saves the objectID of a pointer into the bytestream and increases the mem pointer */ 64 65 template <class T> inline void saveAndIncrease( T*& variable, uint8_t*& mem ) … … 70 71 mem += returnSize( variable ); 71 72 } 72 73 73 74 /** @brief checks whether the objectID of the variable is the same as in the bytestream */ 74 75 template <class T> inline bool checkEquality( T*& variable, uint8_t* mem ) … … 79 80 return variable == variable->getSynchronisable(*(uint32_t*)(mem)); 80 81 } 81 82 82 83 // These functions implement loading / saving / etc. for SmartPtr<T> 83 84 84 85 /** @brief returns the size of the objectID needed to synchronise the pointer */ 85 86 template <class T> inline uint32_t returnSize( const SmartPtr<T>& variable ) … … 87 88 return sizeof(uint32_t); 88 89 } 89 90 90 91 /** @brief reads the objectID of a pointer out of the bytestream and increases the mem pointer */ 91 92 template <class T> inline void loadAndIncrease( const SmartPtr<T>& variable, uint8_t*& mem ) … … 95 96 mem += returnSize( variable ); 96 97 } 97 98 98 99 /** @brief saves the objectID of a pointer into the bytestream and increases the mem pointer */ 99 100 template <class T> inline void saveAndIncrease( const SmartPtr<T>& variable, uint8_t*& mem ) … … 105 106 mem += returnSize( variable ); 106 107 } 107 108 108 109 /** @brief checks whether the objectID of the variable is the same as in the bytestream */ 109 110 template <class T> inline bool checkEquality( const SmartPtr<T>& variable, uint8_t* mem ) … … 114 115 return *(uint32_t*)(mem) == OBJECTID_UNKNOWN; 115 116 } 116 117 117 118 // These functions implement loading / saving / etc. for WeakPtr<T> 118 119 119 120 /** @brief returns the size of the objectID needed to synchronise the pointer */ 120 121 template <class T> inline uint32_t returnSize( const WeakPtr<T>& variable ) … … 122 123 return sizeof(uint32_t); 123 124 } 124 125 125 126 /** @brief reads the objectID of a pointer out of the bytestream and increases the mem pointer */ 126 127 template <class T> inline void loadAndIncrease( const WeakPtr<T>& variable, uint8_t*& mem ) … … 130 131 mem += returnSize( variable ); 131 132 } 132 133 133 134 /** @brief saves the objectID of a pointer into the bytestream and increases the mem pointer */ 134 135 template <class T> inline void saveAndIncrease( const WeakPtr<T>& variable, uint8_t*& mem ) … … 140 141 mem += returnSize( variable ); 141 142 } 142 143 143 144 /** @brief checks whether the objectID of the variable is the same as in the bytestream */ 144 145 template <class T> inline bool checkEquality( const WeakPtr<T>& variable, uint8_t* mem )
Note: See TracChangeset
for help on using the changeset viewer.