MCPcopy Create free account
hub / github.com/cuberite/cuberite / OnConnectionAccepted

Method OnConnectionAccepted

src/Server.cpp:299–328  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

297
298
299void cServer::OnConnectionAccepted(cSocket & a_Socket)
300{
301 if (!a_Socket.IsValid())
302 {
303 return;
304 }
305
306 const AString & ClientIP = a_Socket.GetIPString();
307 if (ClientIP.empty())
308 {
309 LOGWARN("cServer: A client connected, but didn't present its IP, disconnecting.");
310 a_Socket.CloseSocket();
311 return;
312 }
313
314 LOGD("Client \"%s\" connected!", ClientIP.c_str());
315
316 cClientHandle * NewHandle = new cClientHandle(&a_Socket, m_ClientViewDistance);
317 if (!m_SocketThreads.AddClient(a_Socket, NewHandle))
318 {
319 // For some reason SocketThreads have rejected the handle, clean it up
320 LOGERROR("Client \"%s\" cannot be handled, server probably unstable", ClientIP.c_str());
321 a_Socket.CloseSocket();
322 delete NewHandle;
323 return;
324 }
325
326 cCSLock Lock(m_CSClients);
327 m_Clients.push_back(NewHandle);
328}
329
330
331

Callers

nothing calls this directly

Calls 7

LOGWARNFunction · 0.85
LOGERRORFunction · 0.85
emptyMethod · 0.80
c_strMethod · 0.80
IsValidMethod · 0.45
CloseSocketMethod · 0.45
AddClientMethod · 0.45

Tested by

no test coverage detected