Did changes upon pull request's request.
This commit is contained in:
@@ -81,7 +81,7 @@ private:
|
|||||||
std::vector<Events::InputCommand> m_InputCommandBuffer;
|
std::vector<Events::InputCommand> m_InputCommandBuffer;
|
||||||
|
|
||||||
// Private member functions
|
// Private member functions
|
||||||
size_t receive(char* data);
|
size_t receive(char* data);
|
||||||
void disconnect();
|
void disconnect();
|
||||||
void parseMessageType(Packet& packet);
|
void parseMessageType(Packet& packet);
|
||||||
void updateFields(Packet& packet, const ComponentInfo& componentInfo, const EntityID& entityID);
|
void updateFields(Packet& packet, const ComponentInfo& componentInfo, const EntityID& entityID);
|
||||||
@@ -109,7 +109,6 @@ private:
|
|||||||
void sendLocalPlayerTransform();
|
void sendLocalPlayerTransform();
|
||||||
void becomePlayer();
|
void becomePlayer();
|
||||||
void displayServerlist();
|
void displayServerlist();
|
||||||
void popNetworkSegmentOfHeader(Packet& packet);
|
|
||||||
void removeWorld();
|
void removeWorld();
|
||||||
void createMainMenu();
|
void createMainMenu();
|
||||||
// Mapping Logic
|
// Mapping Logic
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ protected:
|
|||||||
void logReceivedData(int bytesReceived);
|
void logReceivedData(int bytesReceived);
|
||||||
void saveToFile();
|
void saveToFile();
|
||||||
void updateNetworkData();
|
void updateNetworkData();
|
||||||
|
void popNetworkSegmentOfHeader(Packet& packet);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -83,7 +83,6 @@ private:
|
|||||||
void kick(PlayerID player);
|
void kick(PlayerID player);
|
||||||
PlayerID getPlayerIDFromEndpoint();
|
PlayerID getPlayerIDFromEndpoint();
|
||||||
PlayerID getPlayerIDFromEntityID(EntityID entityID);
|
PlayerID getPlayerIDFromEntityID(EntityID entityID);
|
||||||
void popNetworkSegmentOfHeader(Packet & packet);
|
|
||||||
void parsePlayerTransform(Packet& packet);
|
void parsePlayerTransform(Packet& packet);
|
||||||
void parseOnInputCommand(Packet& packet);
|
void parseOnInputCommand(Packet& packet);
|
||||||
void parseClientPing();
|
void parseClientPing();
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
class UDPClient : public NetworkClient
|
class UDPClient : public NetworkClient
|
||||||
{
|
{
|
||||||
// TODO: add packets to map.
|
|
||||||
public:
|
public:
|
||||||
UDPClient();
|
UDPClient();
|
||||||
~UDPClient();
|
~UDPClient();
|
||||||
@@ -34,6 +33,8 @@ private:
|
|||||||
//map:(packetGroup, vector:(pair:(groupIndex, packetData)))
|
//map:(packetGroup, vector:(pair:(groupIndex, packetData)))
|
||||||
std::map<unsigned int, std::vector<std::pair<int, boost::shared_ptr<char>>>> m_PacketSegmentMap;
|
std::map<unsigned int, std::vector<std::pair<int, boost::shared_ptr<char>>>> m_PacketSegmentMap;
|
||||||
bool hasReceivedPacket(int packetGroup, int groupIndex);
|
bool hasReceivedPacket(int packetGroup, int groupIndex);
|
||||||
|
// 2^19
|
||||||
|
const int m_SizeOfSocketBuffer = 524288;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -706,15 +706,6 @@ void Client::displayServerlist()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::popNetworkSegmentOfHeader(Packet & packet)
|
|
||||||
{
|
|
||||||
// Pop packetSize, group, groupIndex and groupSize.
|
|
||||||
packet.ReadPrimitive<int>();
|
|
||||||
packet.ReadPrimitive<int>();
|
|
||||||
packet.ReadPrimitive<int>();
|
|
||||||
packet.ReadPrimitive<int>();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Client::removeWorld()
|
void Client::removeWorld()
|
||||||
{
|
{
|
||||||
std::vector<EntityID> childrenToBeDeleted;
|
std::vector<EntityID> childrenToBeDeleted;
|
||||||
|
|||||||
@@ -83,3 +83,12 @@ void Network::updateNetworkData()
|
|||||||
m_NetworkData.DataReceivedThisInterval = 0;
|
m_NetworkData.DataReceivedThisInterval = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Network::popNetworkSegmentOfHeader(Packet & packet)
|
||||||
|
{
|
||||||
|
// Pop packetSize, group, groupIndex and groupSize.
|
||||||
|
packet.ReadPrimitive<int>();
|
||||||
|
packet.ReadPrimitive<int>();
|
||||||
|
packet.ReadPrimitive<int>();
|
||||||
|
packet.ReadPrimitive<int>();
|
||||||
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ void Packet::Init(MessageType type, unsigned int & packetID,
|
|||||||
// allocate memory for size of packet, sequenceNumber and totalPacketesInSequence
|
// allocate memory for size of packet, sequenceNumber and totalPacketesInSequence
|
||||||
packetSizeOffset = m_Offset;
|
packetSizeOffset = m_Offset;
|
||||||
WritePrimitive<int>(0);
|
WritePrimitive<int>(0);
|
||||||
// packetGroup is the gorup the packet is in
|
// packetGroup is the group the packet is in
|
||||||
groupOffset = m_Offset;
|
groupOffset = m_Offset;
|
||||||
WritePrimitive<int>(group);
|
WritePrimitive<int>(group);
|
||||||
// What index the packet has in the packetGroup
|
// What index the packet has in the packetGroup
|
||||||
|
|||||||
@@ -299,8 +299,6 @@ void Server::sendPing()
|
|||||||
reliableBroadcast(packet);
|
reliableBroadcast(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Server::checkForTimeOuts()
|
void Server::checkForTimeOuts()
|
||||||
{
|
{
|
||||||
double startPing = 1000 * m_StartPingTime
|
double startPing = 1000 * m_StartPingTime
|
||||||
@@ -332,10 +330,6 @@ void Server::parseUDPConnect(Packet & packet)
|
|||||||
m_PacketID = packet.ReadPrimitive<int>(); //Read new packet id
|
m_PacketID = packet.ReadPrimitive<int>(); //Read new packet id
|
||||||
// parse player id and other stuff
|
// parse player id and other stuff
|
||||||
PlayerID playerID = packet.ReadPrimitive<int>();
|
PlayerID playerID = packet.ReadPrimitive<int>();
|
||||||
if (!EntityWrapper(m_World, playerID).Valid()) {
|
|
||||||
|
|
||||||
}
|
|
||||||
// Do something here?
|
|
||||||
boost::asio::ip::udp::endpoint endpoint(m_Address, m_Port);
|
boost::asio::ip::udp::endpoint endpoint(m_Address, m_Port);
|
||||||
m_ConnectedPlayers.at(playerID).Endpoint = endpoint;
|
m_ConnectedPlayers.at(playerID).Endpoint = endpoint;
|
||||||
LOG_INFO("parseUDPConnect: Spectator \"%s\" connected on IP: %s", m_ConnectedPlayers.at(playerID).Name.c_str(), m_ConnectedPlayers.at(playerID).Endpoint.address().to_string().c_str());
|
LOG_INFO("parseUDPConnect: Spectator \"%s\" connected on IP: %s", m_ConnectedPlayers.at(playerID).Name.c_str(), m_ConnectedPlayers.at(playerID).Endpoint.address().to_string().c_str());
|
||||||
@@ -357,7 +351,6 @@ void Server::parseTCPConnect(Packet & packet)
|
|||||||
|
|
||||||
LOG_INFO("Parsing connections");
|
LOG_INFO("Parsing connections");
|
||||||
// Check if player is already connected
|
// Check if player is already connected
|
||||||
// Ska vara till lagd i TCPServer receive
|
|
||||||
PlayerID playerID = getPlayerIDFromEndpoint();
|
PlayerID playerID = getPlayerIDFromEndpoint();
|
||||||
if (playerID == -1) {
|
if (playerID == -1) {
|
||||||
LOG_INFO("Server::parseTCPConnect: Not connected");
|
LOG_INFO("Server::parseTCPConnect: Not connected");
|
||||||
@@ -670,13 +663,4 @@ PlayerID Server::getPlayerIDFromEntityID(EntityID entityID)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
void Server::popNetworkSegmentOfHeader(Packet & packet)
|
|
||||||
{
|
|
||||||
// Pop packetSize, group, groupIndex and groupSize.
|
|
||||||
packet.ReadPrimitive<int>();
|
|
||||||
packet.ReadPrimitive<int>();
|
|
||||||
packet.ReadPrimitive<int>();
|
|
||||||
packet.ReadPrimitive<int>();
|
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,7 @@ bool UDPClient::Connect(std::string playerName, std::string address, int port)
|
|||||||
m_ReceiverEndpoint = udp::endpoint(boost::asio::ip::address().from_string(address), port);
|
m_ReceiverEndpoint = udp::endpoint(boost::asio::ip::address().from_string(address), port);
|
||||||
m_Socket = boost::shared_ptr<boost::asio::ip::udp::socket>(new boost::asio::ip::udp::socket(m_IOService));
|
m_Socket = boost::shared_ptr<boost::asio::ip::udp::socket>(new boost::asio::ip::udp::socket(m_IOService));
|
||||||
m_Socket->open(boost::asio::ip::udp::v4());
|
m_Socket->open(boost::asio::ip::udp::v4());
|
||||||
boost::asio::socket_base::receive_buffer_size option(819200);
|
boost::asio::socket_base::receive_buffer_size option(m_SizeOfSocketBuffer);
|
||||||
m_Socket->set_option(option);
|
m_Socket->set_option(option);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user