Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2024
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. void ClientInterface::CreateClient(session_t peer_id)
  2. {
  3. RecursiveMutexAutoLock conlock(m_clients_mutex);
  4.  
  5. // Error check
  6. RemoteClientMap::iterator n = m_clients.find(peer_id);
  7. // The client shouldn't already exist
  8. if (n != m_clients.end()) return;
  9.  
  10. // Create client
  11. RemoteClient *client = new RemoteClient();
  12. client->peer_id = peer_id;
  13. m_clients[client->peer_id] = client;
  14.  
  15.  
  16. Address addr;
  17. std::string addr_s;
  18. try {
  19. addr = m_con->GetPeerAddress(peer_id);
  20. addr_s = addr.serializeString();
  21. } catch (con::PeerNotFoundException &e) {
  22. /*
  23. * no peer for this packet found
  24. * most common reason is peer timeout, e.g. peer didn't
  25. * respond for some time, your server was overloaded or
  26. * things like that.
  27. */
  28. infostream << "error" << std::endl;
  29. return;
  30. }
  31.  
  32. infostream << "got address: " << addr_s << std::endl;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement