mirror of
https://github.com/Heretek-AI/GDevelop.git
synced 2026-07-24 11:55:28 -04:00
a8559bfbbc
* Update all CMakeLists of extensions to use clang-format * Run clang-format on all Extensions * Update GDCore CMakeLists.txt to add clang-format * Run clang-format on GDCore files * Update GDJS and GDCpp CMakeLists.txt to add clang-format * Run clang-format on GDCpp and GDJS files
47 lines
1.2 KiB
C++
47 lines
1.2 KiB
C++
#include "NetworkManager.h"
|
|
#include "ErrorManager.h"
|
|
#include "GDCpp/Runtime/CommonTools.h"
|
|
#include "ReceivedDataManager.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: {
|
|
sf::String title;
|
|
packet >> title;
|
|
double number;
|
|
packet >> number;
|
|
|
|
ReceivedDataManager::Get()->values[title] = number;
|
|
break;
|
|
}
|
|
case 1: {
|
|
sf::String title;
|
|
packet >> title;
|
|
sf::String str;
|
|
packet >> str;
|
|
|
|
ReceivedDataManager::Get()->strings[title] = str;
|
|
break;
|
|
}
|
|
default:
|
|
ErrorManager::Get()->SetLastError("Received unknown data ( Type " +
|
|
gd::String::From(type) + " )\n");
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|