2013-12-06 10:00:58 +01:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
// Created by [Dennis Andersen] [2013]
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef NETWORK_CUSTOM_NETWORK_PROTOCOL_H
|
|
|
|
#define NETWORK_CUSTOM_NETWORK_PROTOCOL_H
|
|
|
|
|
2014-01-31 22:52:52 +01:00
|
|
|
//needs to have dll-interface to be used by clients of class 'Oyster::Network::NetworkSession'
|
|
|
|
#pragma warning(disable : 4251)
|
|
|
|
|
2013-12-06 10:00:58 +01:00
|
|
|
#include <string>
|
2014-01-31 22:52:52 +01:00
|
|
|
#include "Utilities.h"
|
2013-12-18 08:30:58 +01:00
|
|
|
//#include <vld.h>
|
2014-01-28 09:00:02 +01:00
|
|
|
#include "NetworkAPI_Preprocessor.h"
|
2013-12-06 10:00:58 +01:00
|
|
|
|
2013-12-11 21:45:43 +01:00
|
|
|
namespace Oyster
|
2013-12-06 10:00:58 +01:00
|
|
|
{
|
2013-12-11 21:45:43 +01:00
|
|
|
namespace Network
|
2013-12-06 10:00:58 +01:00
|
|
|
{
|
2013-12-11 21:45:43 +01:00
|
|
|
extern "C"
|
2013-12-06 10:00:58 +01:00
|
|
|
{
|
2013-12-11 21:45:43 +01:00
|
|
|
//Please don't create a type with a number higher than 127 for now.
|
|
|
|
//This may increase to 255 later on.
|
|
|
|
enum NetAttributeType
|
|
|
|
{
|
|
|
|
NetAttributeType_Bool,
|
|
|
|
NetAttributeType_Char,
|
|
|
|
NetAttributeType_UnsignedChar,
|
|
|
|
NetAttributeType_Short,
|
|
|
|
NetAttributeType_UnsignedShort,
|
|
|
|
NetAttributeType_Int,
|
|
|
|
NetAttributeType_UnsignedInt,
|
|
|
|
NetAttributeType_Int64,
|
|
|
|
NetAttributeType_UnsignedInt64,
|
|
|
|
NetAttributeType_Float,
|
|
|
|
NetAttributeType_Double,
|
|
|
|
NetAttributeType_CharArray,
|
|
|
|
NetAttributeType_UNKNOWN,
|
|
|
|
};
|
|
|
|
union NetAttributeValue
|
|
|
|
{
|
|
|
|
bool netBool;
|
|
|
|
char netChar;
|
|
|
|
unsigned char netUChar;
|
|
|
|
short netShort;
|
|
|
|
unsigned short netUShort;
|
|
|
|
int netInt;
|
|
|
|
unsigned int netUInt;
|
|
|
|
__int64 netInt64;
|
|
|
|
unsigned __int64 netUInt64;
|
|
|
|
float netFloat;
|
|
|
|
double netDouble;
|
|
|
|
char* netCharPtr;
|
2013-12-09 14:23:30 +01:00
|
|
|
|
2013-12-11 21:45:43 +01:00
|
|
|
NetAttributeValue(){ memset(this, 0, sizeof(NetAttributeValue)); }
|
|
|
|
NetAttributeValue(bool v) : netBool (v) {}
|
|
|
|
NetAttributeValue(char v) : netChar (v) {}
|
|
|
|
NetAttributeValue(unsigned char v) : netUChar (v) {}
|
|
|
|
NetAttributeValue(short v) : netShort (v) {}
|
|
|
|
NetAttributeValue(unsigned short v) : netUShort (v) {}
|
|
|
|
NetAttributeValue(int v) : netInt (v) {}
|
|
|
|
NetAttributeValue(unsigned int v) : netUInt (v) {}
|
|
|
|
NetAttributeValue(__int64 v) : netInt64 (v) {}
|
|
|
|
NetAttributeValue(unsigned __int64 v) : netUInt64 (v) {}
|
|
|
|
NetAttributeValue(float v) : netFloat (v) {}
|
|
|
|
NetAttributeValue(double v) : netDouble (v) {}
|
|
|
|
NetAttributeValue(char* v) : netCharPtr(v) {}
|
|
|
|
};
|
|
|
|
struct NetAttributeContainer
|
|
|
|
{
|
|
|
|
NetAttributeType type;
|
|
|
|
NetAttributeValue value;
|
|
|
|
NetAttributeContainer() { type = NetAttributeType_UNKNOWN; }
|
|
|
|
};
|
|
|
|
class CustomNetProtocol;
|
|
|
|
struct CustomProtocolObject
|
|
|
|
{
|
2014-01-31 22:52:52 +01:00
|
|
|
virtual CustomNetProtocol GetProtocol() = 0;
|
2013-12-11 21:45:43 +01:00
|
|
|
};
|
|
|
|
|
2014-01-28 09:00:02 +01:00
|
|
|
class NET_API_EXPORT CustomNetProtocol
|
2013-12-11 21:45:43 +01:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
CustomNetProtocol();
|
|
|
|
~CustomNetProtocol();
|
2013-12-12 12:17:39 +01:00
|
|
|
CustomNetProtocol(const CustomNetProtocol& o);
|
|
|
|
const CustomNetProtocol& operator=(const CustomNetProtocol& o);
|
2013-12-11 21:45:43 +01:00
|
|
|
|
|
|
|
NetAttributeContainer& operator[](int ID);
|
2014-01-22 15:22:52 +01:00
|
|
|
void Set(int id, Oyster::Network::NetAttributeValue val, Oyster::Network::NetAttributeType type);
|
|
|
|
void Set(int ID, std::string s);
|
|
|
|
const NetAttributeContainer& Get(int id);
|
2013-12-11 21:45:43 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
struct PrivateData;
|
2014-01-31 22:52:52 +01:00
|
|
|
Utility::DynamicMemory::SmartPointer<PrivateData> privateData;
|
2013-12-11 21:45:43 +01:00
|
|
|
|
|
|
|
friend class Translator;
|
|
|
|
};
|
|
|
|
|
|
|
|
}//End extern "C"
|
|
|
|
} //End namespace Network
|
|
|
|
}
|
2013-12-06 10:00:58 +01:00
|
|
|
#endif // !NETWORK_CUSTOM_NETWORK_PROTOCOL_H
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|