Network.cpp 20 KB

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