Moved UDP logic from Hybrid server/client to UDP server/client. fixed bug in Server::CheckForTimeOuts.
This commit is contained in:
@@ -1,25 +1,13 @@
|
||||
#ifndef HybridClient_h__
|
||||
#define HybridClient_h__
|
||||
|
||||
#include "Client.h"
|
||||
|
||||
|
||||
class HybridClient : public Client
|
||||
class HybridClient
|
||||
{
|
||||
public:
|
||||
HybridClient(ConfigFile* config);
|
||||
HybridClient();
|
||||
~HybridClient();
|
||||
void Start(World* world, EventBroker* eventBroker);
|
||||
private:
|
||||
// Assio UDP logic
|
||||
boost::asio::ip::udp::endpoint m_ReceiverEndpoint;
|
||||
boost::asio::io_service m_IOService;
|
||||
boost::asio::ip::udp::socket m_Socket;
|
||||
|
||||
void connect();
|
||||
void readFromServer();
|
||||
int receive(char * data);
|
||||
void send(Packet & packet);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,25 +1,12 @@
|
||||
#ifndef HybridServer_h__
|
||||
#define HybridServer_h__
|
||||
|
||||
#include "Server.h"
|
||||
#include <boost/asio/ip/udp.hpp>
|
||||
|
||||
class HybridServer : public Server
|
||||
class HybridServer
|
||||
{
|
||||
public:
|
||||
HybridServer();
|
||||
~HybridServer();
|
||||
private:
|
||||
// UDP logic
|
||||
boost::asio::io_service m_IOService;
|
||||
std::unique_ptr<boost::asio::ip::udp::socket> m_Socket;
|
||||
boost::asio::ip::udp::endpoint m_ReceiverEndpoint;
|
||||
|
||||
void readFromClients();
|
||||
void parseConnect(Packet & packet);
|
||||
void send(Packet & packet, PlayerDefinition & playerDefinition);
|
||||
void send(Packet & packet);
|
||||
int receive(char * data);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -8,12 +8,11 @@ class TCPClient : public Client
|
||||
public:
|
||||
TCPClient(ConfigFile* config);
|
||||
~TCPClient();
|
||||
void Start(World* world, EventBroker* eventBroker);
|
||||
private:
|
||||
// Assio TCP logic
|
||||
boost::asio::ip::tcp::endpoint m_Endpoint;
|
||||
boost::asio::io_service m_IOService;
|
||||
boost::shared_ptr<boost::asio::ip::tcp::socket> m_Socket;
|
||||
std::unique_ptr<boost::asio::ip::tcp::socket> m_Socket;
|
||||
|
||||
void connect();
|
||||
void readFromServer();
|
||||
|
||||
@@ -13,14 +13,14 @@ private:
|
||||
boost::asio::io_service m_IOService;
|
||||
std::unique_ptr<boost::asio::ip::tcp::acceptor> acceptor;
|
||||
boost::shared_ptr<boost::asio::ip::tcp::socket> lastReceivedSocket;
|
||||
|
||||
void readFromClients();
|
||||
|
||||
void acceptNewConnections();
|
||||
void handle_accept(boost::shared_ptr<boost::asio::ip::tcp::socket> socket, const boost::system::error_code & error);
|
||||
void readFromClients();
|
||||
int receive(char * data, boost::asio::ip::tcp::socket& socket);
|
||||
void parseConnect(Packet & packet);
|
||||
void send(Packet & packet, PlayerDefinition & playerDefinition);
|
||||
void send(Packet & packet);
|
||||
int receive(char * data, boost::asio::ip::tcp::socket& socket);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef UDPClient_h__
|
||||
#define UDPClient_h__
|
||||
|
||||
#include "Client.h"
|
||||
|
||||
|
||||
class UDPClient : public Client
|
||||
{
|
||||
public:
|
||||
UDPClient(ConfigFile* config);
|
||||
~UDPClient();
|
||||
private:
|
||||
// Assio UDP logic
|
||||
boost::asio::io_service m_IOService;
|
||||
boost::asio::ip::udp::endpoint m_ReceiverEndpoint;
|
||||
boost::asio::ip::udp::socket m_Socket;
|
||||
|
||||
void connect();
|
||||
void readFromServer();
|
||||
int receive(char * data);
|
||||
void send(Packet & packet);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef UDPServer_h__
|
||||
#define UDPServer_h__
|
||||
|
||||
#include "Server.h"
|
||||
#include <boost/asio/ip/udp.hpp>
|
||||
|
||||
class UDPServer : public Server
|
||||
{
|
||||
public:
|
||||
UDPServer();
|
||||
~UDPServer();
|
||||
private:
|
||||
// UDP logic
|
||||
boost::asio::io_service m_IOService;
|
||||
boost::asio::ip::udp::endpoint m_ReceiverEndpoint;
|
||||
std::unique_ptr<boost::asio::ip::udp::socket> m_Socket;
|
||||
|
||||
void readFromClients();
|
||||
int receive(char * data);
|
||||
void parseConnect(Packet & packet);
|
||||
void send(Packet & packet, PlayerDefinition & playerDefinition);
|
||||
void send(Packet & packet);
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user