MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Initialize

Method Initialize

Source/Engine/Networking/NetworkPeer.cpp:19–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17}
18
19bool NetworkPeer::Initialize(const NetworkConfig& config)
20{
21 if (NetworkDriver)
22 return true;
23
24 Config = config;
25
26 if (Config.NetworkDriver == nullptr)
27 {
28 LOG(Error, "Missing NetworkDriver");
29 return true;
30 }
31 if (Config.ConnectionsLimit <= 0)
32 {
33 LOG(Error, "Invalid ConnectionsLimit");
34 return true;
35 }
36 if (Config.MessageSize <= 32) // TODO: Adjust this, not sure what the lowest limit should be.
37 {
38 LOG(Error, "Invalid MessageSize");
39 return true;
40 }
41 if (Config.MessagePoolSize <= 128)
42 {
43 LOG(Error, "Invalid MessagePoolSize");
44 return true;
45 }
46 NetworkDriver = ToInterface<INetworkDriver>(Config.NetworkDriver);
47 if (!NetworkDriver)
48 {
49 LOG(Error, "NetworkDriver doesn't implement INetworkDriver interface");
50 return true;
51 }
52
53 // TODO: Dynamic message pool allocation
54 // Setup messages
55 CreateMessageBuffers();
56 MessagePool.Clear();
57
58 // Warmup message pool
59 for (uint32 messageId = Config.MessagePoolSize; messageId > 0; messageId --)
60 MessagePool.Push(messageId);
61
62 // Setup network driver
63 if (NetworkDriver->Initialize(this, Config))
64 {
65 LOG(Error, "Failed to initialize NetworkDriver");
66 return true;
67 }
68
69 LOG(Info, "NetworkPeer initialized using driver = {0}", NetworkDriver->DriverName());
70 return false;
71}
72
73void NetworkPeer::Shutdown()
74{

Callers 5

SendReplicationFunction · 0.45
InvokeObjectReplicationFunction · 0.45
InvokeObjectRpcFunction · 0.45
BeginInvokeRPCMethod · 0.45
CreatePeerMethod · 0.45

Calls 3

DriverNameMethod · 0.80
ClearMethod · 0.45
PushMethod · 0.45

Tested by

no test coverage detected