MCPcopy Create free account
hub / github.com/Panzerschrek/Chasm-Reverse / ConnectToServer

Method ConnectToServer

PanzerChasm/host.cpp:281–314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

279}
280
281void Host::ConnectToServer(
282 const char* server_address,
283 const uint16_t client_tcp_port,
284 const uint16_t client_udp_port )
285{
286 InetAddress address;
287 if( !InetAddress::Parse( server_address , address ) )
288 {
289 Log::User( "Invalid address." );
290 return;
291 }
292
293 if( address.port == 0 )
294 address.port= Net::c_default_server_tcp_port;
295
296 Log::User( "Connecting to ", address.ToString(), "." );
297
298 EnsureClient();
299 EnsureNet();
300
301 ClearBeforeGameStart();
302
303 auto connection= net_->ConnectToServer( address, client_tcp_port, client_udp_port );
304 if( connection == nullptr )
305 {
306 Log::User( "Connection failed." );
307 return;
308 }
309
310 client_->SetConnection( connection );
311
312 if( system_window_ != nullptr )
313 system_window_->SetTitle( base_window_title_ + " - multiplayer client" );
314}
315
316void Host::StartServer(
317 const unsigned int map_number,

Callers 1

ProcessEventMethod · 0.45

Calls 3

ToStringMethod · 0.80
SetConnectionMethod · 0.80
SetTitleMethod · 0.80

Tested by

no test coverage detected