Files
GDevelop/Extensions/Network/NetworkManager.cpp
T
Florian 3331b3a7c6 Added two expressions to get IP addresses.
Minor adaptation to minor changes in GDL.


git-svn-id: svn://localhost@407 8062f311-0dae-4547-b526-b8ab9ac864a5
2011-03-26 22:17:19 +00:00

51 lines
1.4 KiB
C++

#include "NetworkManager.h"
#include "ReceivedDataManager.h"
#include "ErrorManager.h"
#include "GDL/CommonTools.h"
NetworkManager * NetworkManager::_singleton = NULL;
void NetworkManager::ReceivePackets()
{
sf::Packet packet;
sf::IpAddress address;
short unsigned int port;
while ( socket.Receive(packet, address, port) == sf::Socket::Done)
{
//Be sure the sender is not blocked
if ( find(blockedList.begin(), blockedList.end(), address) == blockedList.end())
{
sf::Int32 type = -1;
packet >> type; //Read the primary type of the packet
switch(type)
{
case 0:
{
std::string title;
packet >> title;
double number;
packet >> number;
ReceivedDataManager::GetInstance()->values[title] = number;
break;
}
case 1:
{
std::string title;
packet >> title;
std::string str;
packet >> str;
ReceivedDataManager::GetInstance()->strings[title] = str;
break;
}
default:
ErrorManager::GetInstance()->SetLastError("Received unknown data ( Type "+ToString(type)+" )\n");
break;
}
}
}
}