Network.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. //
  2. // Copyright (c) 2008-2015 the Urho3D project.
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #include "../Precompiled.h"
  23. #include "../Core/Context.h"
  24. #include "../Core/CoreEvents.h"
  25. #include "../Core/Profiler.h"
  26. #include "../Engine/EngineEvents.h"
  27. #include "../IO/FileSystem.h"
  28. #include "../Input/InputEvents.h"
  29. #include "../IO/IOEvents.h"
  30. #include "../IO/Log.h"
  31. #include "../IO/MemoryBuffer.h"
  32. #include "../Network/HttpRequest.h"
  33. #include "../Network/Network.h"
  34. #include "../Network/NetworkEvents.h"
  35. #include "../Network/NetworkPriority.h"
  36. #include "../Network/Protocol.h"
  37. #include "../Scene/Scene.h"
  38. #include <kNet/kNet.h>
  39. #include "../DebugNew.h"
  40. namespace Urho3D
  41. {
  42. static const int DEFAULT_UPDATE_FPS = 30;
  43. Network::Network(Context* context) :
  44. Object(context),
  45. updateFps_(DEFAULT_UPDATE_FPS),
  46. simulatedLatency_(0),
  47. simulatedPacketLoss_(0.0f),
  48. updateInterval_(1.0f / (float)DEFAULT_UPDATE_FPS),
  49. updateAcc_(0.0f)
  50. {
  51. network_ = new kNet::Network();
  52. // Register Network library object factories
  53. RegisterNetworkLibrary(context_);
  54. SubscribeToEvent(E_BEGINFRAME, URHO3D_HANDLER(Network, HandleBeginFrame));
  55. SubscribeToEvent(E_RENDERUPDATE, URHO3D_HANDLER(Network, HandleRenderUpdate));
  56. // Blacklist remote events which are not to be allowed to be registered in any case
  57. blacklistedRemoteEvents_.Insert(E_CONSOLECOMMAND);
  58. blacklistedRemoteEvents_.Insert(E_LOGMESSAGE);
  59. blacklistedRemoteEvents_.Insert(E_BEGINFRAME);
  60. blacklistedRemoteEvents_.Insert(E_UPDATE);
  61. blacklistedRemoteEvents_.Insert(E_POSTUPDATE);
  62. blacklistedRemoteEvents_.Insert(E_RENDERUPDATE);
  63. blacklistedRemoteEvents_.Insert(E_ENDFRAME);
  64. blacklistedRemoteEvents_.Insert(E_MOUSEBUTTONDOWN);
  65. blacklistedRemoteEvents_.Insert(E_MOUSEBUTTONUP);
  66. blacklistedRemoteEvents_.Insert(E_MOUSEMOVE);
  67. blacklistedRemoteEvents_.Insert(E_MOUSEWHEEL);
  68. blacklistedRemoteEvents_.Insert(E_KEYDOWN);
  69. blacklistedRemoteEvents_.Insert(E_KEYUP);
  70. blacklistedRemoteEvents_.Insert(E_TEXTINPUT);
  71. blacklistedRemoteEvents_.Insert(E_JOYSTICKCONNECTED);
  72. blacklistedRemoteEvents_.Insert(E_JOYSTICKDISCONNECTED);
  73. blacklistedRemoteEvents_.Insert(E_JOYSTICKBUTTONDOWN);
  74. blacklistedRemoteEvents_.Insert(E_JOYSTICKBUTTONUP);
  75. blacklistedRemoteEvents_.Insert(E_JOYSTICKAXISMOVE);
  76. blacklistedRemoteEvents_.Insert(E_JOYSTICKHATMOVE);
  77. blacklistedRemoteEvents_.Insert(E_TOUCHBEGIN);
  78. blacklistedRemoteEvents_.Insert(E_TOUCHEND);
  79. blacklistedRemoteEvents_.Insert(E_TOUCHMOVE);
  80. blacklistedRemoteEvents_.Insert(E_GESTURERECORDED);
  81. blacklistedRemoteEvents_.Insert(E_GESTUREINPUT);
  82. blacklistedRemoteEvents_.Insert(E_MULTIGESTURE);
  83. blacklistedRemoteEvents_.Insert(E_DROPFILE);
  84. blacklistedRemoteEvents_.Insert(E_INPUTFOCUS);
  85. blacklistedRemoteEvents_.Insert(E_MOUSEVISIBLECHANGED);
  86. blacklistedRemoteEvents_.Insert(E_EXITREQUESTED);
  87. blacklistedRemoteEvents_.Insert(E_SERVERCONNECTED);
  88. blacklistedRemoteEvents_.Insert(E_SERVERDISCONNECTED);
  89. blacklistedRemoteEvents_.Insert(E_CONNECTFAILED);
  90. blacklistedRemoteEvents_.Insert(E_CLIENTCONNECTED);
  91. blacklistedRemoteEvents_.Insert(E_CLIENTDISCONNECTED);
  92. blacklistedRemoteEvents_.Insert(E_CLIENTIDENTITY);
  93. blacklistedRemoteEvents_.Insert(E_CLIENTSCENELOADED);
  94. blacklistedRemoteEvents_.Insert(E_NETWORKMESSAGE);
  95. blacklistedRemoteEvents_.Insert(E_NETWORKUPDATE);
  96. blacklistedRemoteEvents_.Insert(E_NETWORKUPDATESENT);
  97. blacklistedRemoteEvents_.Insert(E_NETWORKSCENELOADFAILED);
  98. }
  99. Network::~Network()
  100. {
  101. // If server connection exists, disconnect, but do not send an event because we are shutting down
  102. Disconnect(100);
  103. serverConnection_.Reset();
  104. clientConnections_.Clear();
  105. delete network_;
  106. network_ = 0;
  107. }
  108. void Network::HandleMessage(kNet::MessageConnection* source, kNet::packet_id_t packetId, kNet::message_id_t msgId, const char* data,
  109. size_t numBytes)
  110. {
  111. // Only process messages from known sources
  112. Connection* connection = GetConnection(source);
  113. if (connection)
  114. {
  115. MemoryBuffer msg(data, (unsigned)numBytes);
  116. if (connection->ProcessMessage((int)msgId, msg))
  117. return;
  118. // If message was not handled internally, forward as an event
  119. using namespace NetworkMessage;
  120. VariantMap& eventData = GetEventDataMap();
  121. eventData[P_CONNECTION] = connection;
  122. eventData[P_MESSAGEID] = (int)msgId;
  123. eventData[P_DATA].SetBuffer(msg.GetData(), msg.GetSize());
  124. connection->SendEvent(E_NETWORKMESSAGE, eventData);
  125. }
  126. else
  127. LOGWARNING("Discarding message from unknown MessageConnection " + ToString((void*)source));
  128. }
  129. u32 Network::ComputeContentID(kNet::message_id_t msgId, const char* data, size_t numBytes)
  130. {
  131. switch (msgId)
  132. {
  133. case MSG_CONTROLS:
  134. // Return fixed content ID for controls
  135. return CONTROLS_CONTENT_ID;
  136. case MSG_NODELATESTDATA:
  137. case MSG_COMPONENTLATESTDATA:
  138. {
  139. // Return the node or component ID, which is first in the message
  140. MemoryBuffer msg(data, (unsigned)numBytes);
  141. return msg.ReadNetID();
  142. }
  143. default:
  144. // By default return no content ID
  145. return 0;
  146. }
  147. }
  148. void Network::NewConnectionEstablished(kNet::MessageConnection* connection)
  149. {
  150. connection->RegisterInboundMessageHandler(this);
  151. // Create a new client connection corresponding to this MessageConnection
  152. SharedPtr<Connection> newConnection(new Connection(context_, true, kNet::SharedPtr<kNet::MessageConnection>(connection)));
  153. newConnection->ConfigureNetworkSimulator(simulatedLatency_, simulatedPacketLoss_);
  154. clientConnections_[connection] = newConnection;
  155. LOGINFO("Client " + newConnection->ToString() + " connected");
  156. using namespace ClientConnected;
  157. VariantMap& eventData = GetEventDataMap();
  158. eventData[P_CONNECTION] = newConnection;
  159. newConnection->SendEvent(E_CLIENTCONNECTED, eventData);
  160. }
  161. void Network::ClientDisconnected(kNet::MessageConnection* connection)
  162. {
  163. connection->Disconnect(0);
  164. // Remove the client connection that corresponds to this MessageConnection
  165. HashMap<kNet::MessageConnection*, SharedPtr<Connection> >::Iterator i = clientConnections_.Find(connection);
  166. if (i != clientConnections_.End())
  167. {
  168. Connection* connection = i->second_;
  169. LOGINFO("Client " + connection->ToString() + " disconnected");
  170. using namespace ClientDisconnected;
  171. VariantMap& eventData = GetEventDataMap();
  172. eventData[P_CONNECTION] = connection;
  173. connection->SendEvent(E_CLIENTDISCONNECTED, eventData);
  174. clientConnections_.Erase(i);
  175. }
  176. }
  177. bool Network::Connect(const String& address, unsigned short port, Scene* scene, const VariantMap& identity)
  178. {
  179. PROFILE(Connect);
  180. // If a previous connection already exists, disconnect it and wait for some time for the connection to terminate
  181. if (serverConnection_)
  182. {
  183. serverConnection_->Disconnect(100);
  184. OnServerDisconnected();
  185. }
  186. kNet::SharedPtr<kNet::MessageConnection> connection = network_->Connect(address.CString(), port, kNet::SocketOverUDP, this);
  187. if (connection)
  188. {
  189. serverConnection_ = new Connection(context_, false, connection);
  190. serverConnection_->SetScene(scene);
  191. serverConnection_->SetIdentity(identity);
  192. serverConnection_->SetConnectPending(true);
  193. serverConnection_->ConfigureNetworkSimulator(simulatedLatency_, simulatedPacketLoss_);
  194. LOGINFO("Connecting to server " + serverConnection_->ToString());
  195. return true;
  196. }
  197. else
  198. {
  199. LOGERROR("Failed to connect to server " + address + ":" + String(port));
  200. SendEvent(E_CONNECTFAILED);
  201. return false;
  202. }
  203. }
  204. void Network::Disconnect(int waitMSec)
  205. {
  206. if (!serverConnection_)
  207. return;
  208. PROFILE(Disconnect);
  209. serverConnection_->Disconnect(waitMSec);
  210. }
  211. bool Network::StartServer(unsigned short port)
  212. {
  213. if (IsServerRunning())
  214. return true;
  215. PROFILE(StartServer);
  216. if (network_->StartServer(port, kNet::SocketOverUDP, this, true) != 0)
  217. {
  218. LOGINFO("Started server on port " + String(port));
  219. return true;
  220. }
  221. else
  222. {
  223. LOGERROR("Failed to start server on port " + String(port));
  224. return false;
  225. }
  226. }
  227. void Network::StopServer()
  228. {
  229. if (!IsServerRunning())
  230. return;
  231. PROFILE(StopServer);
  232. clientConnections_.Clear();
  233. network_->StopServer();
  234. LOGINFO("Stopped server");
  235. }
  236. void Network::BroadcastMessage(int msgID, bool reliable, bool inOrder, const VectorBuffer& msg, unsigned contentID)
  237. {
  238. BroadcastMessage(msgID, reliable, inOrder, msg.GetData(), msg.GetSize(), contentID);
  239. }
  240. void Network::BroadcastMessage(int msgID, bool reliable, bool inOrder, const unsigned char* data, unsigned numBytes,
  241. unsigned contentID)
  242. {
  243. // Make sure not to use kNet internal message ID's
  244. if (msgID <= 0x4 || msgID >= 0x3ffffffe)
  245. {
  246. LOGERROR("Can not send message with reserved ID");
  247. return;
  248. }
  249. kNet::NetworkServer* server = network_->GetServer();
  250. if (server)
  251. server->BroadcastMessage((unsigned long)msgID, reliable, inOrder, 0, contentID, (const char*)data, numBytes);
  252. else
  253. LOGERROR("Server not running, can not broadcast messages");
  254. }
  255. void Network::BroadcastRemoteEvent(StringHash eventType, bool inOrder, const VariantMap& eventData)
  256. {
  257. for (HashMap<kNet::MessageConnection*, SharedPtr<Connection> >::Iterator i = clientConnections_.Begin();
  258. i != clientConnections_.End(); ++i)
  259. i->second_->SendRemoteEvent(eventType, inOrder, eventData);
  260. }
  261. void Network::BroadcastRemoteEvent(Scene* scene, StringHash eventType, bool inOrder, const VariantMap& eventData)
  262. {
  263. for (HashMap<kNet::MessageConnection*, SharedPtr<Connection> >::Iterator i = clientConnections_.Begin();
  264. i != clientConnections_.End(); ++i)
  265. {
  266. if (i->second_->GetScene() == scene)
  267. i->second_->SendRemoteEvent(eventType, inOrder, eventData);
  268. }
  269. }
  270. void Network::BroadcastRemoteEvent(Node* node, StringHash eventType, bool inOrder, const VariantMap& eventData)
  271. {
  272. if (!node)
  273. {
  274. LOGERROR("Null sender node for remote node event");
  275. return;
  276. }
  277. if (node->GetID() >= FIRST_LOCAL_ID)
  278. {
  279. LOGERROR("Sender node has a local ID, can not send remote node event");
  280. return;
  281. }
  282. Scene* scene = node->GetScene();
  283. for (HashMap<kNet::MessageConnection*, SharedPtr<Connection> >::Iterator i = clientConnections_.Begin();
  284. i != clientConnections_.End(); ++i)
  285. {
  286. if (i->second_->GetScene() == scene)
  287. i->second_->SendRemoteEvent(node, eventType, inOrder, eventData);
  288. }
  289. }
  290. void Network::SetUpdateFps(int fps)
  291. {
  292. updateFps_ = Max(fps, 1);
  293. updateInterval_ = 1.0f / (float)updateFps_;
  294. updateAcc_ = 0.0f;
  295. }
  296. void Network::SetSimulatedLatency(int ms)
  297. {
  298. simulatedLatency_ = Max(ms, 0);
  299. ConfigureNetworkSimulator();
  300. }
  301. void Network::SetSimulatedPacketLoss(float loss)
  302. {
  303. simulatedPacketLoss_ = Clamp(loss, 0.0f, 1.0f);
  304. ConfigureNetworkSimulator();
  305. }
  306. void Network::RegisterRemoteEvent(StringHash eventType)
  307. {
  308. if (blacklistedRemoteEvents_.Find(eventType) != blacklistedRemoteEvents_.End())
  309. {
  310. LOGERROR("Attempted to register blacklisted remote event type " + String(eventType));
  311. return;
  312. }
  313. allowedRemoteEvents_.Insert(eventType);
  314. }
  315. void Network::UnregisterRemoteEvent(StringHash eventType)
  316. {
  317. allowedRemoteEvents_.Erase(eventType);
  318. }
  319. void Network::UnregisterAllRemoteEvents()
  320. {
  321. allowedRemoteEvents_.Clear();
  322. }
  323. void Network::SetPackageCacheDir(const String& path)
  324. {
  325. packageCacheDir_ = AddTrailingSlash(path);
  326. }
  327. void Network::SendPackageToClients(Scene* scene, PackageFile* package)
  328. {
  329. if (!scene)
  330. {
  331. LOGERROR("Null scene specified for SendPackageToClients");
  332. return;
  333. }
  334. if (!package)
  335. {
  336. LOGERROR("Null package specified for SendPackageToClients");
  337. return;
  338. }
  339. for (HashMap<kNet::MessageConnection*, SharedPtr<Connection> >::Iterator i = clientConnections_.Begin();
  340. i != clientConnections_.End(); ++i)
  341. {
  342. if (i->second_->GetScene() == scene)
  343. i->second_->SendPackageToClient(package);
  344. }
  345. }
  346. SharedPtr<HttpRequest> Network::MakeHttpRequest(const String& url, const String& verb, const Vector<String>& headers,
  347. const String& postData)
  348. {
  349. PROFILE(MakeHttpRequest);
  350. // The initialization of the request will take time, can not know at this point if it has an error or not
  351. SharedPtr<HttpRequest> request(new HttpRequest(url, verb, headers, postData));
  352. return request;
  353. }
  354. Connection* Network::GetConnection(kNet::MessageConnection* connection) const
  355. {
  356. if (serverConnection_ && serverConnection_->GetMessageConnection() == connection)
  357. return serverConnection_;
  358. else
  359. {
  360. HashMap<kNet::MessageConnection*, SharedPtr<Connection> >::ConstIterator i = clientConnections_.Find(connection);
  361. if (i != clientConnections_.End())
  362. return i->second_;
  363. else
  364. return 0;
  365. }
  366. }
  367. Connection* Network::GetServerConnection() const
  368. {
  369. return serverConnection_;
  370. }
  371. Vector<SharedPtr<Connection> > Network::GetClientConnections() const
  372. {
  373. Vector<SharedPtr<Connection> > ret;
  374. for (HashMap<kNet::MessageConnection*, SharedPtr<Connection> >::ConstIterator i = clientConnections_.Begin();
  375. i != clientConnections_.End(); ++i)
  376. ret.Push(i->second_);
  377. return ret;
  378. }
  379. bool Network::IsServerRunning() const
  380. {
  381. return network_->GetServer();
  382. }
  383. bool Network::CheckRemoteEvent(StringHash eventType) const
  384. {
  385. return allowedRemoteEvents_.Contains(eventType);
  386. }
  387. void Network::Update(float timeStep)
  388. {
  389. PROFILE(UpdateNetwork);
  390. // Process server connection if it exists
  391. if (serverConnection_)
  392. {
  393. kNet::MessageConnection* connection = serverConnection_->GetMessageConnection();
  394. // Receive new messages
  395. connection->Process();
  396. // Process latest data messages waiting for the correct nodes or components to be created
  397. serverConnection_->ProcessPendingLatestData();
  398. // Check for state transitions
  399. kNet::ConnectionState state = connection->GetConnectionState();
  400. if (serverConnection_->IsConnectPending() && state == kNet::ConnectionOK)
  401. OnServerConnected();
  402. else if (state == kNet::ConnectionPeerClosed)
  403. serverConnection_->Disconnect();
  404. else if (state == kNet::ConnectionClosed)
  405. OnServerDisconnected();
  406. }
  407. // Process the network server if started
  408. kNet::SharedPtr<kNet::NetworkServer> server = network_->GetServer();
  409. if (server)
  410. server->Process();
  411. }
  412. void Network::PostUpdate(float timeStep)
  413. {
  414. PROFILE(PostUpdateNetwork);
  415. // Check if periodic update should happen now
  416. updateAcc_ += timeStep;
  417. bool updateNow = updateAcc_ >= updateInterval_;
  418. if (updateNow)
  419. {
  420. // Notify of the impending update to allow for example updated client controls to be set
  421. SendEvent(E_NETWORKUPDATE);
  422. updateAcc_ = fmodf(updateAcc_, updateInterval_);
  423. if (IsServerRunning())
  424. {
  425. // Collect and prepare all networked scenes
  426. {
  427. PROFILE(PrepareServerUpdate);
  428. networkScenes_.Clear();
  429. for (HashMap<kNet::MessageConnection*, SharedPtr<Connection> >::Iterator i = clientConnections_.Begin();
  430. i != clientConnections_.End(); ++i)
  431. {
  432. Scene* scene = i->second_->GetScene();
  433. if (scene)
  434. networkScenes_.Insert(scene);
  435. }
  436. for (HashSet<Scene*>::ConstIterator i = networkScenes_.Begin(); i != networkScenes_.End(); ++i)
  437. (*i)->PrepareNetworkUpdate();
  438. }
  439. {
  440. PROFILE(SendServerUpdate);
  441. // Then send server updates for each client connection
  442. for (HashMap<kNet::MessageConnection*, SharedPtr<Connection> >::Iterator i = clientConnections_.Begin();
  443. i != clientConnections_.End(); ++i)
  444. {
  445. i->second_->SendServerUpdate();
  446. i->second_->SendRemoteEvents();
  447. i->second_->SendPackages();
  448. }
  449. }
  450. }
  451. if (serverConnection_)
  452. {
  453. // Send the client update
  454. serverConnection_->SendClientUpdate();
  455. serverConnection_->SendRemoteEvents();
  456. }
  457. // Notify that the update was sent
  458. SendEvent(E_NETWORKUPDATESENT);
  459. }
  460. }
  461. void Network::HandleBeginFrame(StringHash eventType, VariantMap& eventData)
  462. {
  463. using namespace BeginFrame;
  464. Update(eventData[P_TIMESTEP].GetFloat());
  465. }
  466. void Network::HandleRenderUpdate(StringHash eventType, VariantMap& eventData)
  467. {
  468. using namespace RenderUpdate;
  469. PostUpdate(eventData[P_TIMESTEP].GetFloat());
  470. }
  471. void Network::OnServerConnected()
  472. {
  473. serverConnection_->SetConnectPending(false);
  474. LOGINFO("Connected to server");
  475. // Send the identity map now
  476. VectorBuffer msg;
  477. msg.WriteVariantMap(serverConnection_->GetIdentity());
  478. serverConnection_->SendMessage(MSG_IDENTITY, true, true, msg);
  479. SendEvent(E_SERVERCONNECTED);
  480. }
  481. void Network::OnServerDisconnected()
  482. {
  483. // Differentiate between failed connection, and disconnection
  484. bool failedConnect = serverConnection_ && serverConnection_->IsConnectPending();
  485. serverConnection_.Reset();
  486. if (!failedConnect)
  487. {
  488. LOGINFO("Disconnected from server");
  489. SendEvent(E_SERVERDISCONNECTED);
  490. }
  491. else
  492. {
  493. LOGERROR("Failed to connect to server");
  494. SendEvent(E_CONNECTFAILED);
  495. }
  496. }
  497. void Network::ConfigureNetworkSimulator()
  498. {
  499. if (serverConnection_)
  500. serverConnection_->ConfigureNetworkSimulator(simulatedLatency_, simulatedPacketLoss_);
  501. for (HashMap<kNet::MessageConnection*, SharedPtr<Connection> >::Iterator i = clientConnections_.Begin();
  502. i != clientConnections_.End(); ++i)
  503. i->second_->ConfigureNetworkSimulator(simulatedLatency_, simulatedPacketLoss_);
  504. }
  505. void RegisterNetworkLibrary(Context* context)
  506. {
  507. NetworkPriority::RegisterObject(context);
  508. }
  509. }