MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / notifyClientMessage

Method notifyClientMessage

source/network/ODServer.cpp:1868–1902  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1866}
1867
1868bool ODServer::notifyClientMessage(ODSocketClient *clientSocket)
1869{
1870 bool ret = processClientNotifications(clientSocket);
1871 if(!ret)
1872 {
1873 std::string nick = clientSocket->getPlayer() ? clientSocket->getPlayer()->getNick() : std::string();
1874 std::string message = nick.empty() ?
1875 "Client disconnected state=" + clientSocket->getState() :
1876 "Client (" + nick + ") disconnected state=" + clientSocket->getState();
1877 OD_LOG_INF(message);
1878 if(std::string("ready").compare(clientSocket->getState()) == 0)
1879 {
1880 for(Player* player : mGameMap->getPlayers())
1881 {
1882 if(!player->getIsHuman())
1883 continue;
1884
1885 ServerNotification *serverNotification = new ServerNotification(
1886 ServerNotificationType::chatServer, player);
1887 std::string msg = nick.empty() ?
1888 "A client disconnected." :
1889 nick + " disconnected.";
1890 serverNotification->mPacket << msg << EventShortNoticeType::genericGameInfo;
1891 queueServerNotification(serverNotification);
1892 }
1893 }
1894
1895 if(mSeatsConfigured)
1896 {
1897 mDisconnectedPlayers.push_back(clientSocket->getPlayer());
1898 }
1899 // TODO : wait at least 1 minute if the client reconnects if deconnexion happens during game
1900 }
1901 return ret;
1902}
1903
1904void ODServer::stopServer()
1905{

Callers

nothing calls this directly

Calls 2

getIsHumanMethod · 0.80
getPlayerMethod · 0.45

Tested by

no test coverage detected