We can now send more data with UDP than previously, the splitting seems to work fine but receiving has some problems.
This commit is contained in:
@@ -59,10 +59,11 @@ public:
|
||||
void UpdateSize();
|
||||
char* ReadData(int SizeOfData);
|
||||
void ChangePacketID(unsigned int& packetID);
|
||||
void ChangeSequenceNumber(int sequenceNumber, int sequenceLength);
|
||||
void ChangeSequenceNumber(int sequenceNumber, int sequenceLength, int groupNumber);
|
||||
size_t Size() { return m_Offset; };
|
||||
char* Data() { return m_Data; };
|
||||
MessageType GetMessageType();
|
||||
size_t Group();
|
||||
size_t DataReadSize() { return m_ReturnDataOffset; }
|
||||
size_t MaxSize() { return m_MaxPacketSize; }
|
||||
size_t HeaderSize() { return m_HeaderSize; }
|
||||
|
||||
@@ -14,6 +14,7 @@ struct PlayerDefinition {
|
||||
unsigned short TCPPort;
|
||||
// use for tcp connections
|
||||
boost::shared_ptr<boost::asio::ip::tcp::socket> TCPSocket;
|
||||
int PacketGroup = 1;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef UDPClient_h__
|
||||
#define UDPClient_h__
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
|
||||
#include <boost/asio.hpp>
|
||||
#include "Network/NetworkClient.h"
|
||||
@@ -15,18 +16,23 @@ public:
|
||||
void Connect(std::string playerName, std::string address, int port);
|
||||
void Disconnect();
|
||||
void Receive(Packet& packet);
|
||||
void Send(Packet & packet);
|
||||
void ReceivePackets();
|
||||
void Send(Packet& packet);
|
||||
void Broadcast(Packet& packet, int port);
|
||||
bool IsSocketAvailable();
|
||||
// Returns false if no packets are available
|
||||
bool GetNextPacket(Packet& packet);
|
||||
private:
|
||||
// Assio UDP logic
|
||||
boost::asio::io_service m_IOService;
|
||||
boost::asio::ip::udp::endpoint m_ReceiverEndpoint;
|
||||
boost::shared_ptr<boost::asio::ip::udp::socket> m_Socket;
|
||||
int lastReceivedSnapshotGroup = 0;
|
||||
int readBuffer();
|
||||
PacketID m_SendPacketID = 0;
|
||||
//map:(packetGroup, vector:(pair:(groupIndex, packetData)))
|
||||
std::map<unsigned int, std::vector<std::pair<unsigned int, boost::shared_ptr<char>>>> packetSegmentMap;
|
||||
std::map<unsigned int, std::vector<std::pair<int, boost::shared_ptr<char>>>> m_PacketSegmentMap;
|
||||
bool hasReceivedPacket(int packetGroup, int groupIndex);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "NetworkServer.h"
|
||||
#include <boost/asio/ip/udp.hpp>
|
||||
#define MAXPACKETSIZE 32000
|
||||
#define MAXPACKETSIZE 64000
|
||||
|
||||
class UDPServer : public NetworkServer
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user