Network.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. //
  2. // Copyright (c) 2008-2014 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 "../Engine/EngineEvents.h"
  26. #include "../IO/FileSystem.h"
  27. #include "../Network/HttpRequest.h"
  28. #include "../Input/InputEvents.h"
  29. #include "../IO/IOEvents.h"
  30. #include "../IO/Log.h"
  31. #include "../IO/MemoryBuffer.h"
  32. #include "../Network/Network.h"
  33. #include "../Network/NetworkEvents.h"
  34. #include "../Network/NetworkPriority.h"
  35. #include "../Core/Profiler.h"
  36. #include "../Network/Protocol.h"
  37. #include "../Scene/Scene.h"
  38. #include <kNet.h>
  39. #include "../DebugNew.h"
  40. namespace Atomic
  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, HANDLER(Network, HandleBeginFrame));
  55. SubscribeToEvent(E_RENDERUPDATE, 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, size_t numBytes)
  109. {
  110. // Only process messages from known sources
  111. Connection* connection = GetConnection(source);
  112. if (connection)
  113. {
  114. MemoryBuffer msg(data, (unsigned)numBytes);
  115. if (connection->ProcessMessage(msgId, msg))
  116. return;
  117. // If message was not handled internally, forward as an event
  118. using namespace NetworkMessage;
  119. VariantMap& eventData = GetEventDataMap();
  120. eventData[P_CONNECTION] = connection;
  121. eventData[P_MESSAGEID] = (int)msgId;
  122. eventData[P_DATA].SetBuffer(msg.GetData(), msg.GetSize());
  123. connection->SendEvent(E_NETWORKMESSAGE, eventData);
  124. }
  125. else
  126. LOGWARNING("Discarding message from unknown MessageConnection " + ToString((void*)source));
  127. }
  128. u32 Network::ComputeContentID(kNet::message_id_t msgId, const char* data, size_t numBytes)
  129. {
  130. switch (msgId)
  131. {
  132. case MSG_CONTROLS:
  133. // Return fixed content ID for controls
  134. return CONTROLS_CONTENT_ID;
  135. case MSG_NODELATESTDATA:
  136. case MSG_COMPONENTLATESTDATA:
  137. {
  138. // Return the node or component ID, which is first in the message
  139. MemoryBuffer msg(data, (unsigned)numBytes);
  140. return msg.ReadNetID();
  141. }
  142. default:
  143. // By default return no content ID
  144. return 0;
  145. }
  146. }
  147. void Network::NewConnectionEstablished(kNet::MessageConnection* connection)
  148. {
  149. connection->RegisterInboundMessageHandler(this);
  150. // Create a new client connection corresponding to this MessageConnection
  151. SharedPtr<Connection> newConnection(new Connection(context_, true, kNet::SharedPtr<kNet::MessageConnection>(connection)));
  152. newConnection->ConfigureNetworkSimulator(simulatedLatency_, simulatedPacketLoss_);
  153. clientConnections_[connection] = newConnection;
  154. LOGINFO("Client " + newConnection->ToString() + " connected");
  155. using namespace ClientConnected;
  156. VariantMap& eventData = GetEventDataMap();
  157. eventData[P_CONNECTION] = newConnection;
  158. newConnection->SendEvent(E_CLIENTCONNECTED, eventData);
  159. }
  160. void Network::ClientDisconnected(kNet::MessageConnection* connection)
  161. {
  162. connection->Disconnect(0);
  163. // Remove the client connection that corresponds to this MessageConnection
  164. HashMap<kNet::MessageConnection*, SharedPtr<Connection> >::Iterator i = clientConnections_.Find(connection);
  165. if (i != clientConnections_.End())
  166. {
  167. Connection* connection = i->second_;
  168. LOGINFO("Client " + connection->ToString() + " disconnected");
  169. using namespace ClientDisconnected;
  170. VariantMap& eventData = GetEventDataMap();
  171. eventData[P_CONNECTION] = connection;
  172. connection->SendEvent(E_CLIENTDISCONNECTED, eventData);
  173. clientConnections_.Erase(i);
  174. }
  175. }
  176. bool Network::Connect(const String& address, unsigned short port, Scene* scene, const VariantMap& identity)
  177. {
  178. PROFILE(Connect);
  179. // If a previous connection already exists, disconnect it and wait for some time for the connection to terminate
  180. if (serverConnection_)
  181. {
  182. serverConnection_->Disconnect(100);
  183. OnServerDisconnected();
  184. }
  185. kNet::SharedPtr<kNet::MessageConnection> connection = network_->Connect(address.CString(), port, kNet::SocketOverUDP, this);
  186. if (connection)
  187. {
  188. serverConnection_ = new Connection(context_, false, connection);
  189. serverConnection_->SetScene(scene);
  190. serverConnection_->SetIdentity(identity);
  191. serverConnection_->SetConnectPending(true);
  192. serverConnection_->ConfigureNetworkSimulator(simulatedLatency_, simulatedPacketLoss_);
  193. LOGINFO("Connecting to server " + serverConnection_->ToString());
  194. return true;
  195. }
  196. else
  197. {
  198. LOGERROR("Failed to connect to server " + address + ":" + String(port));
  199. SendEvent(E_CONNECTFAILED);
  200. return false;
  201. }
  202. }
  203. void Network::Disconnect(int waitMSec)
  204. {
  205. if (!serverConnection_)
  206. return;
  207. PROFILE(Disconnect);
  208. serverConnection_->Disconnect(waitMSec);
  209. }
  210. bool Network::StartServer(unsigned short port)
  211. {
  212. if (IsServerRunning())
  213. return true;
  214. PROFILE(StartServer);
  215. if (network_->StartServer(port, kNet::SocketOverUDP, this, true) != 0)
  216. {
  217. LOGINFO("Started server on port " + String(port));
  218. return true;
  219. }
  220. else
  221. {
  222. LOGERROR("Failed to start server on port " + String(port));
  223. return false;
  224. }
  225. }
  226. void Network::StopServer()
  227. {
  228. if (!IsServerRunning())
  229. return;
  230. PROFILE(StopServer);
  231. clientConnections_.Clear();
  232. network_->StopServer();
  233. LOGINFO("Stopped server");
  234. }
  235. void Network::BroadcastMessage(int msgID, bool reliable, bool inOrder, const VectorBuffer& msg, unsigned contentID)
  236. {
  237. BroadcastMessage(msgID, reliable, inOrder, msg.GetData(), msg.GetSize(), contentID);
  238. }
  239. void Network::BroadcastMessage(int msgID, bool reliable, bool inOrder, const unsigned char* data, unsigned numBytes,
  240. unsigned contentID)
  241. {
  242. // Make sure not to use kNet internal message ID's
  243. if (msgID <= 0x4 || msgID >= 0x3ffffffe)
  244. {
  245. LOGERROR("Can not send message with reserved ID");
  246. return;
  247. }
  248. kNet::NetworkServer* server = network_->GetServer();
  249. if (server)
  250. server->BroadcastMessage(msgID, reliable, inOrder, 0, contentID, (const char*)data, numBytes);
  251. else
  252. LOGERROR("Server not running, can not broadcast messages");
  253. }
  254. void Network::BroadcastRemoteEvent(StringHash eventType, bool inOrder, const VariantMap& eventData)
  255. {
  256. for (HashMap<kNet::MessageConnection*, SharedPtr<Connection> >::Iterator i = clientConnections_.Begin();
  257. i != clientConnections_.End(); ++i)
  258. i->second_->SendRemoteEvent(eventType, inOrder, eventData);
  259. }
  260. void Network::BroadcastRemoteEvent(Scene* scene, StringHash eventType, bool inOrder, const VariantMap& eventData)
  261. {
  262. for (HashMap<kNet::MessageConnection*, SharedPtr<Connection> >::Iterator i = clientConnections_.Begin();
  263. i != clientConnections_.End(); ++i)
  264. {
  265. if (i->second_->GetScene() == scene)
  266. i->second_->SendRemoteEvent(eventType, inOrder, eventData);
  267. }
  268. }
  269. void Network::BroadcastRemoteEvent(Node* node, StringHash eventType, bool inOrder, const VariantMap& eventData)
  270. {
  271. if (!node)
  272. {
  273. LOGERROR("Null sender node for remote node event");
  274. return;
  275. }
  276. if (node->GetID() >= FIRST_LOCAL_ID)
  277. {
  278. LOGERROR("Sender node has a local ID, can not send remote node event");
  279. return;
  280. }
  281. Scene* scene = node->GetScene();
  282. for (HashMap<kNet::MessageConnection*, SharedPtr<Connection> >::Iterator i = clientConnections_.Begin();
  283. i != clientConnections_.End(); ++i)
  284. {
  285. if (i->second_->GetScene() == scene)
  286. i->second_->SendRemoteEvent(node, eventType, inOrder, eventData);
  287. }
  288. }
  289. void Network::SetUpdateFps(int fps)
  290. {
  291. updateFps_ = Max(fps, 1);
  292. updateInterval_ = 1.0f / (float)updateFps_;
  293. updateAcc_ = 0.0f;
  294. }
  295. void Network::SetSimulatedLatency(int ms)
  296. {
  297. simulatedLatency_ = Max(ms, 0);
  298. ConfigureNetworkSimulator();
  299. }
  300. void Network::SetSimulatedPacketLoss(float loss)
  301. {
  302. simulatedPacketLoss_ = Clamp(loss, 0.0f, 1.0f);
  303. ConfigureNetworkSimulator();
  304. }
  305. void Network::RegisterRemoteEvent(StringHash eventType)
  306. {
  307. if (blacklistedRemoteEvents_.Find(eventType) != blacklistedRemoteEvents_.End())
  308. {
  309. LOGERROR("Attempted to register blacklisted remote event type " + String(eventType));
  310. return;
  311. }
  312. allowedRemoteEvents_.Insert(eventType);
  313. }
  314. void Network::UnregisterRemoteEvent(StringHash eventType)
  315. {
  316. allowedRemoteEvents_.Erase(eventType);
  317. }
  318. void Network::UnregisterAllRemoteEvents()
  319. {
  320. allowedRemoteEvents_.Clear();
  321. }
  322. void Network::SetPackageCacheDir(const String& path)
  323. {
  324. packageCacheDir_ = AddTrailingSlash(path);
  325. }
  326. void Network::SendPackageToClients(Scene* scene, PackageFile* package)
  327. {
  328. if (!scene)
  329. {
  330. LOGERROR("Null scene specified for SendPackageToClients");
  331. return;
  332. }
  333. if (!package)
  334. {
  335. LOGERROR("Null package specified for SendPackageToClients");
  336. return;
  337. }
  338. for (HashMap<kNet::MessageConnection*, SharedPtr<Connection> >::Iterator i = clientConnections_.Begin();
  339. i != clientConnections_.End(); ++i)
  340. {
  341. if (i->second_->GetScene() == scene)
  342. i->second_->SendPackageToClient(package);
  343. }
  344. }
  345. SharedPtr<HttpRequest> Network::MakeHttpRequest(const String& url, const String& verb, const Vector<String>& headers, const String& postData)
  346. {
  347. PROFILE(MakeHttpRequest);
  348. // The initialization of the request will take time, can not know at this point if it has an error or not
  349. SharedPtr<HttpRequest> request(new HttpRequest(url, verb, headers, postData));
  350. return request;
  351. }
  352. Connection* Network::GetConnection(kNet::MessageConnection* connection) const
  353. {
  354. if (serverConnection_ && serverConnection_->GetMessageConnection() == connection)
  355. return serverConnection_;
  356. else
  357. {
  358. HashMap<kNet::MessageConnection*, SharedPtr<Connection> >::ConstIterator i = clientConnections_.Find(connection);
  359. if (i != clientConnections_.End())
  360. return i->second_;
  361. else
  362. return 0;
  363. }
  364. }
  365. Connection* Network::GetServerConnection() const
  366. {
  367. return serverConnection_;
  368. }
  369. Vector<SharedPtr<Connection> > Network::GetClientConnections() const
  370. {
  371. Vector<SharedPtr<Connection> > ret;
  372. for (HashMap<kNet::MessageConnection*, SharedPtr<Connection> >::ConstIterator i = clientConnections_.Begin();
  373. i != clientConnections_.End(); ++i)
  374. ret.Push(i->second_);
  375. return ret;
  376. }
  377. bool Network::IsServerRunning() const
  378. {
  379. return network_->GetServer();
  380. }
  381. bool Network::CheckRemoteEvent(StringHash eventType) const
  382. {
  383. return allowedRemoteEvents_.Contains(eventType);
  384. }
  385. void Network::Update(float timeStep)
  386. {
  387. PROFILE(UpdateNetwork);
  388. // Process server connection if it exists
  389. if (serverConnection_)
  390. {
  391. kNet::MessageConnection* connection = serverConnection_->GetMessageConnection();
  392. // Receive new messages
  393. connection->Process();
  394. // Process latest data messages waiting for the correct nodes or components to be created
  395. serverConnection_->ProcessPendingLatestData();
  396. // Check for state transitions
  397. kNet::ConnectionState state = connection->GetConnectionState();
  398. if (serverConnection_->IsConnectPending() && state == kNet::ConnectionOK)
  399. OnServerConnected();
  400. else if (state == kNet::ConnectionPeerClosed)
  401. serverConnection_->Disconnect();
  402. else if (state == kNet::ConnectionClosed)
  403. OnServerDisconnected();
  404. }
  405. // Process the network server if started
  406. kNet::SharedPtr<kNet::NetworkServer> server = network_->GetServer();
  407. if (server)
  408. server->Process();
  409. }
  410. void Network::PostUpdate(float timeStep)
  411. {
  412. PROFILE(PostUpdateNetwork);
  413. // Check if periodic update should happen now
  414. updateAcc_ += timeStep;
  415. bool updateNow = updateAcc_ >= updateInterval_;
  416. if (updateNow)
  417. {
  418. // Notify of the impending update to allow for example updated client controls to be set
  419. SendEvent(E_NETWORKUPDATE);
  420. updateAcc_ = fmodf(updateAcc_, updateInterval_);
  421. if (IsServerRunning())
  422. {
  423. // Collect and prepare all networked scenes
  424. {
  425. PROFILE(PrepareServerUpdate);
  426. networkScenes_.Clear();
  427. for (HashMap<kNet::MessageConnection*, SharedPtr<Connection> >::Iterator i = clientConnections_.Begin();
  428. i != clientConnections_.End(); ++i)
  429. {
  430. Scene* scene = i->second_->GetScene();
  431. if (scene)
  432. networkScenes_.Insert(scene);
  433. }
  434. for (HashSet<Scene*>::ConstIterator i = networkScenes_.Begin(); i != networkScenes_.End(); ++i)
  435. (*i)->PrepareNetworkUpdate();
  436. }
  437. {
  438. PROFILE(SendServerUpdate);
  439. // Then send server updates for each client connection
  440. for (HashMap<kNet::MessageConnection*, SharedPtr<Connection> >::Iterator i = clientConnections_.Begin();
  441. i != clientConnections_.End(); ++i)
  442. {
  443. i->second_->SendServerUpdate();
  444. i->second_->SendRemoteEvents();
  445. i->second_->SendPackages();
  446. }
  447. }
  448. }
  449. if (serverConnection_)
  450. {
  451. // Send the client update
  452. serverConnection_->SendClientUpdate();
  453. serverConnection_->SendRemoteEvents();
  454. }
  455. // Notify that the update was sent
  456. SendEvent(E_NETWORKUPDATESENT);
  457. }
  458. }
  459. void Network::HandleBeginFrame(StringHash eventType, VariantMap& eventData)
  460. {
  461. using namespace BeginFrame;
  462. Update(eventData[P_TIMESTEP].GetFloat());
  463. }
  464. void Network::HandleRenderUpdate(StringHash eventType, VariantMap& eventData)
  465. {
  466. using namespace RenderUpdate;
  467. PostUpdate(eventData[P_TIMESTEP].GetFloat());
  468. }
  469. void Network::OnServerConnected()
  470. {
  471. serverConnection_->SetConnectPending(false);
  472. LOGINFO("Connected to server");
  473. // Send the identity map now
  474. VectorBuffer msg;
  475. msg.WriteVariantMap(serverConnection_->GetIdentity());
  476. serverConnection_->SendMessage(MSG_IDENTITY, true, true, msg);
  477. SendEvent(E_SERVERCONNECTED);
  478. }
  479. void Network::OnServerDisconnected()
  480. {
  481. // Differentiate between failed connection, and disconnection
  482. bool failedConnect = serverConnection_ && serverConnection_->IsConnectPending();
  483. serverConnection_.Reset();
  484. if (!failedConnect)
  485. {
  486. LOGINFO("Disconnected from server");
  487. SendEvent(E_SERVERDISCONNECTED);
  488. }
  489. else
  490. {
  491. LOGERROR("Failed to connect to server");
  492. SendEvent(E_CONNECTFAILED);
  493. }
  494. }
  495. void Network::ConfigureNetworkSimulator()
  496. {
  497. if (serverConnection_)
  498. serverConnection_->ConfigureNetworkSimulator(simulatedLatency_, simulatedPacketLoss_);
  499. for (HashMap<kNet::MessageConnection*, SharedPtr<Connection> >::Iterator i = clientConnections_.Begin();
  500. i != clientConnections_.End(); ++i)
  501. i->second_->ConfigureNetworkSimulator(simulatedLatency_, simulatedPacketLoss_);
  502. }
  503. void RegisterNetworkLibrary(Context* context)
  504. {
  505. NetworkPriority::RegisterObject(context);
  506. }
  507. }