Merge remote-tracking branch 'origin/Networking' into Networking
# Conflicts: # src/Engine/Network/Client.cpp
This commit is contained in:
@@ -5,10 +5,10 @@
|
||||
#include <ctime>
|
||||
|
||||
#include <glm/common.hpp>
|
||||
#include <boost/asio.hpp>
|
||||
|
||||
#include "Network/Network.h"
|
||||
#include "Network/MessageType.h"
|
||||
#include "Network/NetworkDefinitions.h"
|
||||
#include "Network/PlayerDefinition.h"
|
||||
#include "Network/SnapshotDefinitions.h"
|
||||
#include "Core/World.h"
|
||||
@@ -21,8 +21,8 @@ class Client : public Network
|
||||
public:
|
||||
Client(ConfigFile* config);
|
||||
~Client();
|
||||
void Start(World* world, EventBroker* eventBroker);
|
||||
void Update();
|
||||
void Start(World* world, EventBroker* eventBroker) override;
|
||||
void Update() override;
|
||||
void Close();
|
||||
private:
|
||||
// Assio UDP logic
|
||||
|
||||
@@ -5,15 +5,15 @@
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Network/Packet.h"
|
||||
|
||||
#define MAXCONNECTIONS 8
|
||||
#define INPUTSIZE 128
|
||||
|
||||
class Network
|
||||
{
|
||||
public:
|
||||
Network();
|
||||
~Network();
|
||||
virtual void Start(World* m_world, EventBroker *eventBroker);
|
||||
virtual void Update();
|
||||
protected:
|
||||
|
||||
virtual ~Network() { };
|
||||
virtual void Start(World* m_world, EventBroker *eventBroker) = 0;
|
||||
virtual void Update() = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,20 +0,0 @@
|
||||
#ifndef NetworkDefines_h__
|
||||
#define NetworkDefines_h__
|
||||
|
||||
#include <boost/asio/ip/udp.hpp>
|
||||
#include <queue>
|
||||
#include "Network/Packet.h"
|
||||
|
||||
|
||||
#define BOARDSIZE 16
|
||||
#define MAXCONNECTIONS 8
|
||||
#define INPUTSIZE 128
|
||||
#define PLAYERSPEED 0.2f;
|
||||
|
||||
typedef boost::shared_ptr<boost::asio::ip::udp::socket> socket_ptr;
|
||||
typedef boost::shared_ptr<std::string> string_ptr;
|
||||
typedef boost::shared_ptr<std::queue<string_ptr>> messageQueue_ptr;
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -20,6 +20,10 @@ public:
|
||||
template<typename T>
|
||||
void WritePrimitive(T val)
|
||||
{
|
||||
// Check if we are trying to add more than the package can fit.
|
||||
if (m_MaxPacketSize < m_Offset + sizeof(T)) {
|
||||
LOG_WARNING("Packet AddPrimitive(): You are trying to add more than we have allocated for!");
|
||||
}
|
||||
memcpy(m_Data + m_Offset, &val, sizeof(T));
|
||||
m_Offset += sizeof(T);
|
||||
}
|
||||
@@ -28,7 +32,7 @@ public:
|
||||
T ReadPrimitive()
|
||||
{
|
||||
if (m_Offset < m_ReturnDataOffset + sizeof(T)) {
|
||||
LOG_WARNING("Packaet PopFrontPrimitive(): You are trying to remove more than what exists in this packet!");
|
||||
LOG_WARNING("Packet PopFrontPrimitive(): You are trying to remove more than what exists in this packet!");
|
||||
return -1;
|
||||
}
|
||||
T returnValue;
|
||||
@@ -51,6 +55,7 @@ private:
|
||||
char* m_Data;
|
||||
unsigned int m_ReturnDataOffset = 0;
|
||||
int m_Offset = 0;
|
||||
unsigned int m_MaxPacketSize = 128;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -5,9 +5,9 @@
|
||||
#include <ctime>
|
||||
|
||||
#include <glm/common.hpp>
|
||||
#include <boost/asio/ip/udp.hpp>
|
||||
|
||||
#include "Network/MessageType.h"
|
||||
#include "Network/NetworkDefinitions.h"
|
||||
#include "Network/PlayerDefinition.h"
|
||||
#include "Core/World.h"
|
||||
#include "Core/EventBroker.h"
|
||||
@@ -18,8 +18,8 @@ class Server : public Network
|
||||
public:
|
||||
Server();
|
||||
~Server();
|
||||
void Start(World* m_world, EventBroker *eventBroker);
|
||||
void Update();
|
||||
void Start(World* m_world, EventBroker *eventBroker) override;
|
||||
void Update() override;
|
||||
void Close();
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user