bored of writing commit messages >.<

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/hilnius@13161 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hilnius 2013-07-10 13:44:30 +00:00
parent 6199524440
commit 8ca4b62038
4 changed files with 21 additions and 5 deletions

View File

@ -55,6 +55,12 @@ void* waitInput(void* data)
{
ProtocolManager::getInstance()->requestStart(new ConnectToServer(n));
}
else
{
NetworkString msg("\0\0");
msg += str;
NetworkManager::getInstance()->getPeers()[0]->sendPacket(msg);
}
}
exit(0);

View File

@ -244,8 +244,7 @@ void ProtocolManager::update()
if (event->type == EVENT_TYPE_MESSAGE)
{
if (event->data.size() > 0)
searchedProtocol = (PROTOCOL_TYPE)(event->data.getUInt8(0));
event->removeFront(1); // remove the first byte which indicates the protocol
searchedProtocol = (PROTOCOL_TYPE)(event->data.getAndRemoveUInt8());
}
if (event->type == EVENT_TYPE_CONNECTED)
{
@ -256,6 +255,10 @@ void ProtocolManager::update()
if (m_protocols[i].protocol->getProtocolType() == searchedProtocol || event->type == EVENT_TYPE_DISCONNECTED) // pass data to protocols even when paused
m_protocols[i].protocol->notifyEvent(event);
}
if (searchedProtocol == PROTOCOL_NONE) // no protocol was aimed, show the msg to debug
{
Log::debug("ProtocolManager", "Message is \"%s\"", event->data.c_str());
}
delete event;
}

View File

@ -46,6 +46,10 @@ void* waitInput2(void* data)
{
stop = true;
}
else if (str == "kickall")
{
ServerNetworkManager::getInstance()->kickAllPlayers();
}
}
uint32_t id = ProtocolManager::getInstance()->requestStart(new StopServer());
@ -89,9 +93,12 @@ void ServerNetworkManager::run()
NetworkManager::run();
}
void ServerNetworkManager::start()
void ServerNetworkManager::kickAllPlayers()
{
for (int i = 0; i < m_peers.size(); i++)
{
m_peers[i]->disconnect();
}
}
void ServerNetworkManager::sendPacket(const NetworkString& data)

View File

@ -33,7 +33,7 @@ class ServerNetworkManager : public NetworkManager
virtual void run();
void start();
void kickAllPlayers();
virtual void sendPacket(const NetworkString& data);