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

Method Connect

Source/Engine/Networking/Drivers/ENetDriver.cpp:112–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112bool ENetDriver::Connect()
113{
114 LOG(Info, "Connecting using ENet...");
115
116 ENetAddress address = { 0 };
117 address.port = _config.Port;
118 enet_address_set_host(&address, _config.Address.ToStringAnsi().GetText());
119
120 // Create ENet host
121 _host = enet_host_create(nullptr, 1, 1, 0, 0);
122 if (_host == nullptr)
123 {
124 LOG(Error, "Failed to initialize ENet host!");
125 return false;
126 }
127
128 // Create ENet peer/connect to the server
129 _peer = enet_host_connect(_host, &address, 1, 0);
130 if (_peer == nullptr)
131 {
132 LOG(Error, "Failed to create ENet host!");
133 enet_host_destroy(_host);
134 return false;
135 }
136
137 return true;
138}
139
140void ENetDriver::Disconnect()
141{

Callers

nothing calls this directly

Calls 5

enet_host_createFunction · 0.85
enet_host_connectFunction · 0.85
enet_host_destroyFunction · 0.85
GetTextMethod · 0.45
ToStringAnsiMethod · 0.45

Tested by

no test coverage detected