Network - Fixed bugg, and small fixed
Using sizeof in MessageHeader class. Fixed bugg in Translator.
This commit is contained in:
parent
092f83a084
commit
2ddb984a2b
|
@ -57,8 +57,7 @@ struct Translator::PrivateData
|
||||||
auto end = ((MyCastingStruct*)protocol.privateData)->attributes.end();
|
auto end = ((MyCastingStruct*)protocol.privateData)->attributes.end();
|
||||||
|
|
||||||
size = 4; //size(int)
|
size = 4; //size(int)
|
||||||
bytes->AddSize(4);
|
message.PackInt(size, *bytes);
|
||||||
message.SetSize(size);
|
|
||||||
|
|
||||||
//Find all the data types
|
//Find all the data types
|
||||||
for(; it != end; it++)
|
for(; it != end; it++)
|
||||||
|
|
|
@ -17,7 +17,6 @@ Listener::Listener(Oyster::Network::IPostBox<int>* postBox)
|
||||||
|
|
||||||
Listener::~Listener()
|
Listener::~Listener()
|
||||||
{
|
{
|
||||||
Stop();
|
|
||||||
if(connection)
|
if(connection)
|
||||||
{
|
{
|
||||||
delete connection;
|
delete connection;
|
||||||
|
|
|
@ -41,72 +41,72 @@ void MessageHeader::Unpack(OysterByte& bytes, ProtocolHeader& header)
|
||||||
|
|
||||||
void MessageHeader::PackBool(bool i, OysterByte& bytes)
|
void MessageHeader::PackBool(bool i, OysterByte& bytes)
|
||||||
{
|
{
|
||||||
bytes.AddSize(1);
|
bytes.AddSize(sizeof(i));
|
||||||
Packing::Pack(&bytes.GetByteArray()[size], i);
|
Packing::Pack(&bytes.GetByteArray()[size], i);
|
||||||
size += 1;
|
size += sizeof(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageHeader::PackChar(char i, OysterByte& bytes)
|
void MessageHeader::PackChar(char i, OysterByte& bytes)
|
||||||
{
|
{
|
||||||
bytes.AddSize(1);
|
bytes.AddSize(sizeof(i));
|
||||||
Packing::Pack(&bytes.GetByteArray()[size], i);
|
Packing::Pack(&bytes.GetByteArray()[size], i);
|
||||||
size += 1;
|
size += sizeof(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageHeader::PackUnsignedChar(unsigned char i, OysterByte& bytes)
|
void MessageHeader::PackUnsignedChar(unsigned char i, OysterByte& bytes)
|
||||||
{
|
{
|
||||||
bytes.AddSize(1);
|
bytes.AddSize(sizeof(i));
|
||||||
Packing::Pack(&bytes.GetByteArray()[size], i);
|
Packing::Pack(&bytes.GetByteArray()[size], i);
|
||||||
size += 1;
|
size += sizeof(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageHeader::PackShort(short i, OysterByte& bytes)
|
void MessageHeader::PackShort(short i, OysterByte& bytes)
|
||||||
{
|
{
|
||||||
bytes.AddSize(2);
|
bytes.AddSize(sizeof(i));
|
||||||
Packing::Pack(&bytes.GetByteArray()[size], i);
|
Packing::Pack(&bytes.GetByteArray()[size], i);
|
||||||
size += 2;
|
size += sizeof(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageHeader::PackUnsignedShort(unsigned short i, OysterByte& bytes)
|
void MessageHeader::PackUnsignedShort(unsigned short i, OysterByte& bytes)
|
||||||
{
|
{
|
||||||
bytes.AddSize(2);
|
bytes.AddSize(sizeof(i));
|
||||||
Packing::Pack(&bytes.GetByteArray()[size], i);
|
Packing::Pack(&bytes.GetByteArray()[size], i);
|
||||||
size += 2;
|
size += sizeof(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageHeader::PackInt(int i, OysterByte& bytes)
|
void MessageHeader::PackInt(int i, OysterByte& bytes)
|
||||||
{
|
{
|
||||||
bytes.AddSize(4);
|
bytes.AddSize(sizeof(i));
|
||||||
Packing::Pack(&bytes.GetByteArray()[size], i);
|
Packing::Pack(&bytes.GetByteArray()[size], i);
|
||||||
size += 4;
|
size += sizeof(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageHeader::PackUnsignedInt(unsigned int i, OysterByte& bytes)
|
void MessageHeader::PackUnsignedInt(unsigned int i, OysterByte& bytes)
|
||||||
{
|
{
|
||||||
bytes.AddSize(4);
|
bytes.AddSize(sizeof(i));
|
||||||
Packing::Pack(&bytes.GetByteArray()[size], i);
|
Packing::Pack(&bytes.GetByteArray()[size], i);
|
||||||
size += 4;
|
size += sizeof(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageHeader::PackInt64(__int64 i, OysterByte& bytes)
|
void MessageHeader::PackInt64(__int64 i, OysterByte& bytes)
|
||||||
{
|
{
|
||||||
bytes.AddSize(8);
|
bytes.AddSize(sizeof(i));
|
||||||
Packing::Pack(&bytes.GetByteArray()[size], i);
|
Packing::Pack(&bytes.GetByteArray()[size], i);
|
||||||
size += 8;
|
size += sizeof(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageHeader::PackUnsignedInt64(unsigned __int64 i, OysterByte& bytes)
|
void MessageHeader::PackUnsignedInt64(unsigned __int64 i, OysterByte& bytes)
|
||||||
{
|
{
|
||||||
bytes.AddSize(8);
|
bytes.AddSize(sizeof(i));
|
||||||
Packing::Pack(&bytes.GetByteArray()[size], i);
|
Packing::Pack(&bytes.GetByteArray()[size], i);
|
||||||
size += 8;
|
size += sizeof(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageHeader::PackFloat(float i, OysterByte& bytes)
|
void MessageHeader::PackFloat(float i, OysterByte& bytes)
|
||||||
{
|
{
|
||||||
bytes.AddSize(4);
|
bytes.AddSize(sizeof(i));
|
||||||
Packing::Pack(&bytes.GetByteArray()[size], i);
|
Packing::Pack(&bytes.GetByteArray()[size], i);
|
||||||
size += 4;
|
size += sizeof(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageHeader::PackFloat(float i[], unsigned int elementCount, OysterByte& bytes)
|
void MessageHeader::PackFloat(float i[], unsigned int elementCount, OysterByte& bytes)
|
||||||
|
@ -123,14 +123,14 @@ void MessageHeader::PackFloat(float i[], unsigned int elementCount, OysterByte&
|
||||||
|
|
||||||
void MessageHeader::PackDouble(double i, OysterByte& bytes)
|
void MessageHeader::PackDouble(double i, OysterByte& bytes)
|
||||||
{
|
{
|
||||||
bytes.AddSize(8);
|
bytes.AddSize(sizeof(i));
|
||||||
Packing::Pack(&bytes.GetByteArray()[size], i);
|
Packing::Pack(&bytes.GetByteArray()[size], i);
|
||||||
size += 8;
|
size += sizeof(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageHeader::PackStr(char str[], OysterByte& bytes)
|
void MessageHeader::PackStr(char str[], OysterByte& bytes)
|
||||||
{
|
{
|
||||||
int totalSize = 2 + (int)strlen(str);
|
int totalSize = sizeof(short) + (int)strlen(str);
|
||||||
bytes.AddSize(totalSize);
|
bytes.AddSize(totalSize);
|
||||||
Packing::Pack(&bytes.GetByteArray()[size], str);
|
Packing::Pack(&bytes.GetByteArray()[size], str);
|
||||||
size += totalSize;
|
size += totalSize;
|
||||||
|
@ -138,7 +138,7 @@ void MessageHeader::PackStr(char str[], OysterByte& bytes)
|
||||||
|
|
||||||
void MessageHeader::PackStr(std::string str, OysterByte& bytes)
|
void MessageHeader::PackStr(std::string str, OysterByte& bytes)
|
||||||
{
|
{
|
||||||
int totalSize = 2 + (int)str.length();
|
int totalSize = sizeof(short) + (int)str.length();
|
||||||
bytes.AddSize(totalSize);
|
bytes.AddSize(totalSize);
|
||||||
Packing::Pack(&bytes.GetByteArray()[size], str);
|
Packing::Pack(&bytes.GetByteArray()[size], str);
|
||||||
size += totalSize;
|
size += totalSize;
|
||||||
|
@ -151,70 +151,70 @@ void MessageHeader::PackStr(std::string str, OysterByte& bytes)
|
||||||
bool MessageHeader::UnpackBool(OysterByte& bytes)
|
bool MessageHeader::UnpackBool(OysterByte& bytes)
|
||||||
{
|
{
|
||||||
bool i = Packing::Unpackb(&bytes.GetByteArray()[size]);
|
bool i = Packing::Unpackb(&bytes.GetByteArray()[size]);
|
||||||
size += 1;
|
size += sizeof(i);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
char MessageHeader::UnpackChar(OysterByte& bytes)
|
char MessageHeader::UnpackChar(OysterByte& bytes)
|
||||||
{
|
{
|
||||||
char i = Packing::Unpackc(&bytes.GetByteArray()[size]);
|
char i = Packing::Unpackc(&bytes.GetByteArray()[size]);
|
||||||
size += 1;
|
size += sizeof(i);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char MessageHeader::UnpackUnsignedChar(OysterByte& bytes)
|
unsigned char MessageHeader::UnpackUnsignedChar(OysterByte& bytes)
|
||||||
{
|
{
|
||||||
unsigned char i = Packing::UnpackC(&bytes.GetByteArray()[size]);
|
unsigned char i = Packing::UnpackC(&bytes.GetByteArray()[size]);
|
||||||
size += 1;
|
size += sizeof(i);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
short MessageHeader::UnpackShort(OysterByte& bytes)
|
short MessageHeader::UnpackShort(OysterByte& bytes)
|
||||||
{
|
{
|
||||||
short i = Packing::Unpacks(&bytes.GetByteArray()[size]);
|
short i = Packing::Unpacks(&bytes.GetByteArray()[size]);
|
||||||
size += 2;
|
size += sizeof(i);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short MessageHeader::UnpackUnsignedShort(OysterByte& bytes)
|
unsigned short MessageHeader::UnpackUnsignedShort(OysterByte& bytes)
|
||||||
{
|
{
|
||||||
unsigned short i = Packing::UnpackS(&bytes.GetByteArray()[size]);
|
unsigned short i = Packing::UnpackS(&bytes.GetByteArray()[size]);
|
||||||
size += 2;
|
size += sizeof(i);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MessageHeader::UnpackInt(OysterByte& bytes)
|
int MessageHeader::UnpackInt(OysterByte& bytes)
|
||||||
{
|
{
|
||||||
int i = Packing::Unpacki(&bytes.GetByteArray()[size]);
|
int i = Packing::Unpacki(&bytes.GetByteArray()[size]);
|
||||||
size += 4;
|
size += sizeof(i);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int MessageHeader::UnpackUnsignedInt(OysterByte& bytes)
|
unsigned int MessageHeader::UnpackUnsignedInt(OysterByte& bytes)
|
||||||
{
|
{
|
||||||
unsigned int i = Packing::UnpackI(&bytes.GetByteArray()[size]);
|
unsigned int i = Packing::UnpackI(&bytes.GetByteArray()[size]);
|
||||||
size += 4;
|
size += sizeof(i);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
__int64 MessageHeader::UnpackInt64(OysterByte& bytes)
|
__int64 MessageHeader::UnpackInt64(OysterByte& bytes)
|
||||||
{
|
{
|
||||||
__int64 i = Packing::Unpacki64(&bytes.GetByteArray()[size]);
|
__int64 i = Packing::Unpacki64(&bytes.GetByteArray()[size]);
|
||||||
size += 8;
|
size += sizeof(i);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned __int64 MessageHeader::UnpackUnsignedInt64(OysterByte& bytes)
|
unsigned __int64 MessageHeader::UnpackUnsignedInt64(OysterByte& bytes)
|
||||||
{
|
{
|
||||||
unsigned __int64 i = Packing::UnpackI64(&bytes.GetByteArray()[size]);
|
unsigned __int64 i = Packing::UnpackI64(&bytes.GetByteArray()[size]);
|
||||||
size += 8;
|
size += sizeof(i);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
float MessageHeader::UnpackFloat(OysterByte& bytes)
|
float MessageHeader::UnpackFloat(OysterByte& bytes)
|
||||||
{
|
{
|
||||||
float i = Packing::Unpackf(&bytes.GetByteArray()[size]);
|
float i = Packing::Unpackf(&bytes.GetByteArray()[size]);
|
||||||
size += 4;
|
size += sizeof(i);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,21 +236,21 @@ float* MessageHeader::UnpackFloat(unsigned int& elementCount, OysterByte& bytes)
|
||||||
double MessageHeader::UnpackDouble(OysterByte& bytes)
|
double MessageHeader::UnpackDouble(OysterByte& bytes)
|
||||||
{
|
{
|
||||||
double i = Packing::Unpackd(&bytes.GetByteArray()[size]);
|
double i = Packing::Unpackd(&bytes.GetByteArray()[size]);
|
||||||
size += 8;
|
size += sizeof(i);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* MessageHeader::UnpackCStr(OysterByte& bytes)
|
char* MessageHeader::UnpackCStr(OysterByte& bytes)
|
||||||
{
|
{
|
||||||
char* str = Packing::UnpackCStr(&bytes.GetByteArray()[size]);
|
char* str = Packing::UnpackCStr(&bytes.GetByteArray()[size]);
|
||||||
size += 2 + (int)strlen(str);
|
size += sizeof(short) + (int)strlen(str);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string MessageHeader::UnpackStr(OysterByte& bytes)
|
std::string MessageHeader::UnpackStr(OysterByte& bytes)
|
||||||
{
|
{
|
||||||
std::string str = Packing::UnpackStr(&bytes.GetByteArray()[size]);
|
std::string str = Packing::UnpackStr(&bytes.GetByteArray()[size]);
|
||||||
size += 2 + (int)str.length();
|
size += sizeof(short) + (int)str.length();
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ OysterByte::OysterByte(int cap)
|
||||||
|
|
||||||
OysterByte::OysterByte(const OysterByte& obj)
|
OysterByte::OysterByte(const OysterByte& obj)
|
||||||
{
|
{
|
||||||
//delete[] this->byteArray;
|
|
||||||
this->byteArray = new unsigned char[obj.capacity];
|
this->byteArray = new unsigned char[obj.capacity];
|
||||||
|
|
||||||
for(int i = 0; i < (int)obj.size; i++)
|
for(int i = 0; i < (int)obj.size; i++)
|
||||||
|
|
|
@ -19,24 +19,30 @@ namespace Oyster
|
||||||
OysterByte(const OysterByte& obj);
|
OysterByte(const OysterByte& obj);
|
||||||
virtual ~OysterByte();
|
virtual ~OysterByte();
|
||||||
|
|
||||||
void Clear(); //Resets size to 0
|
//Resets size to 0
|
||||||
void Resize(unsigned int cap); //Resizes the array with, it does not keep anything in it.
|
void Clear();
|
||||||
|
|
||||||
|
//Resizes the array with, it does not keep anything in it.
|
||||||
|
void Resize(unsigned int cap);
|
||||||
|
|
||||||
int GetSize();
|
int GetSize();
|
||||||
unsigned char* GetByteArray();
|
unsigned char* GetByteArray();
|
||||||
|
|
||||||
void AddSize(unsigned int size);
|
void AddSize(unsigned int size);
|
||||||
void SetBytes(unsigned char* bytes);
|
void SetBytes(unsigned char* bytes);
|
||||||
void SetSize(unsigned int size); //Only sets the private variable 'size'
|
|
||||||
|
//Only sets the private variable 'size'
|
||||||
|
void SetSize(unsigned int size);
|
||||||
|
|
||||||
OysterByte& operator =(const OysterByte& obj);
|
OysterByte& operator =(const OysterByte& obj);
|
||||||
|
|
||||||
operator char*();
|
operator char*();
|
||||||
operator const char*();
|
operator const char*();
|
||||||
operator unsigned char*();
|
operator unsigned char*();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void IncreaseCapacity(unsigned int cap); //Expands the byteArray
|
//Expands the byteArray
|
||||||
|
void IncreaseCapacity(unsigned int cap);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "../NetworkDependencies/ThreadedClient.h"
|
#include "../NetworkDependencies/ThreadedClient.h"
|
||||||
#include "../../Misc/WinTimer.h"
|
#include "../../Misc/WinTimer.h"
|
||||||
#include "../../Misc/Utilities.h"
|
#include "../../Misc/Utilities.h"
|
||||||
|
#include "../NetworkAPI/NetworkClient.h"
|
||||||
|
|
||||||
#pragma comment(lib, "ws2_32.lib")
|
#pragma comment(lib, "ws2_32.lib")
|
||||||
|
|
||||||
|
@ -20,6 +21,11 @@ using namespace Utility::DynamicMemory;
|
||||||
void chat(ThreadedClient &client);
|
void chat(ThreadedClient &client);
|
||||||
void PrintOutMessage(ProtocolSet* set);
|
void PrintOutMessage(ProtocolSet* set);
|
||||||
|
|
||||||
|
void proc(CustomNetProtocol& protocol)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
int errorCode;
|
int errorCode;
|
||||||
|
@ -31,10 +37,11 @@ int main()
|
||||||
cout << "Client" << endl;
|
cout << "Client" << endl;
|
||||||
|
|
||||||
//Create Client
|
//Create Client
|
||||||
ThreadedClient* client = new ThreadedClient;
|
NetworkClient client;
|
||||||
|
|
||||||
//Connect to server
|
//Connect to server
|
||||||
errorCode = client->Connect(15151, "193.11.186.101");
|
errorCode = client.Connect(15151, "193.11.186.101");
|
||||||
|
client.SetRecieverObject(proc, NetworkProtocolCallbackType_Function);
|
||||||
|
|
||||||
if(errorCode != 0)
|
if(errorCode != 0)
|
||||||
{
|
{
|
||||||
|
@ -42,94 +49,13 @@ int main()
|
||||||
wcout << "errorMessage: " << errorTest << endl;
|
wcout << "errorMessage: " << errorTest << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
chat(*client);
|
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete client;
|
|
||||||
|
|
||||||
ShutdownWinSock();
|
ShutdownWinSock();
|
||||||
|
|
||||||
system("pause");
|
system("pause");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
void chat(ThreadedClient &client)
|
|
||||||
{
|
|
||||||
/*Oyster::Network::Translator *t = new Oyster::Network::Translator();
|
|
||||||
IPostBox< SmartPointer<OysterByte >> *postBox = new PostBox< SmartPointer<OysterByte >>;
|
|
||||||
|
|
||||||
//client.setRecvPostBox(postBox);
|
|
||||||
|
|
||||||
SmartPointer<OysterByte> msgRecv = new OysterByte();
|
|
||||||
SmartPointer<OysterByte> msgSend = new OysterByte();
|
|
||||||
|
|
||||||
ProtocolSet* set = new ProtocolSet;
|
|
||||||
ProtocolPlayerPos test;
|
|
||||||
test.ID = 5;
|
|
||||||
test.nrOfFloats = 5;
|
|
||||||
test.matrix = new float[test.nrOfFloats];
|
|
||||||
float temp = 10;
|
|
||||||
for(int i = 0; i < (int)test.nrOfFloats; i++)
|
|
||||||
{
|
|
||||||
test.matrix[i] = temp;
|
|
||||||
temp++;
|
|
||||||
}
|
|
||||||
t->Pack(test, msgSend);
|
|
||||||
|
|
||||||
WinTimer timer;
|
|
||||||
|
|
||||||
while(1)
|
|
||||||
{
|
|
||||||
//Fetch new messages from the postbox
|
|
||||||
//if(postBox->FetchMessage(msgRecv))
|
|
||||||
{
|
|
||||||
t->Unpack(set, msgRecv);
|
|
||||||
|
|
||||||
//PrintOutMessage(set);
|
|
||||||
set->Release();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Send message to server each second
|
|
||||||
if(timer.getElapsedSeconds() > 1)
|
|
||||||
{
|
|
||||||
cout << "Sending to server." << endl;
|
|
||||||
timer.reset();
|
|
||||||
//client.Send(msgSend);
|
|
||||||
}
|
|
||||||
Sleep(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete postBox;
|
|
||||||
delete t;
|
|
||||||
delete set;*/
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrintOutMessage(ProtocolSet* set)
|
|
||||||
{
|
|
||||||
switch(set->type)
|
|
||||||
{
|
|
||||||
case PackageType_header:
|
|
||||||
break;
|
|
||||||
case PackageType_test:
|
|
||||||
cout <<"Client 2: " << set->Protocol.pTest->textMessage <<endl;
|
|
||||||
for(int i = 0; i < (int)set->Protocol.pTest->numOfFloats; i++)
|
|
||||||
{
|
|
||||||
cout << set->Protocol.pTest->f[i] << ' ' ;
|
|
||||||
}
|
|
||||||
cout << endl;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PackageType_player_pos:
|
|
||||||
cout << "ID " << set->Protocol.pPlayerPos->ID << endl;
|
|
||||||
for(int i = 0; i < (int)set->Protocol.pPlayerPos->nrOfFloats; i++)
|
|
||||||
{
|
|
||||||
cout << set->Protocol.pPlayerPos->matrix[i] << ' ';
|
|
||||||
}
|
|
||||||
cout << endl;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -73,21 +73,21 @@
|
||||||
<LibraryPath>$(OutDir)..\DLL\;$(LibraryPath);$(SolutionDir)..\External\Lib\NetworkAPI;$(SolutionDir)..\Bin\DLL;C:\Program Files (x86)\Visual Leak Detector\lib\Win32</LibraryPath>
|
<LibraryPath>$(OutDir)..\DLL\;$(LibraryPath);$(SolutionDir)..\External\Lib\NetworkAPI;$(SolutionDir)..\Bin\DLL;C:\Program Files (x86)\Visual Leak Detector\lib\Win32</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
<IncludePath>C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
<IncludePath>C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>C:\Program Files (x86)\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
<LibraryPath>C:\Program Files (x86)\Visual Leak Detector\lib\Win32;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
|
||||||
<IncludePath>C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
<IncludePath>C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>C:\Program Files (x86)\Visual Leak Detector\lib\Win64;$(LibraryPath)</LibraryPath>
|
<LibraryPath>C:\Program Files (x86)\Visual Leak Detector\lib\Win64;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
|
<OutDir>$(SolutionDir)..\Bin\Executable\</OutDir>
|
||||||
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
|
||||||
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
|
||||||
<IncludePath>C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
<IncludePath>C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)</IncludePath>
|
||||||
|
|
|
@ -160,10 +160,6 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="ServerMain.cpp" />
|
<ClCompile Include="ServerMain.cpp" />
|
||||||
<ClCompile Include="TestClass.cpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="TestClass.h" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
|
|
@ -18,13 +18,5 @@
|
||||||
<ClCompile Include="ServerMain.cpp">
|
<ClCompile Include="ServerMain.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="TestClass.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="TestClass.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -2,7 +2,6 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <vld.h>
|
#include <vld.h>
|
||||||
#include "../NetworkDependencies/WinsockFunctions.h"
|
#include "../NetworkDependencies/WinsockFunctions.h"
|
||||||
#include "../NetworkAPI/Translator.h"
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
|
@ -1,84 +0,0 @@
|
||||||
#include "TestClass.h"
|
|
||||||
#include "../../Misc/WinTimer.h"
|
|
||||||
#include <iostream>
|
|
||||||
/*
|
|
||||||
using namespace Oyster::Network;
|
|
||||||
using namespace ::Protocols;
|
|
||||||
using namespace Utility;
|
|
||||||
using namespace ::DynamicMemory;
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
Test::Test()
|
|
||||||
{
|
|
||||||
recvPostBox = new PostBox<SmartPointer<OysterByte>>;
|
|
||||||
|
|
||||||
sendBuffer = new OysterByte;
|
|
||||||
recvBuffer = new OysterByte;
|
|
||||||
|
|
||||||
NetworkServer::INIT_DESC initDesc;
|
|
||||||
initDesc.port = 9876;
|
|
||||||
server.Init(initDesc);
|
|
||||||
server.Start();
|
|
||||||
|
|
||||||
test.clientID = 0;
|
|
||||||
test.ID = 5;
|
|
||||||
test.nrOfFloats = 10;
|
|
||||||
test.matrix = new float[test.nrOfFloats];
|
|
||||||
|
|
||||||
for(int i = 0; i < (int)test.nrOfFloats; i++)
|
|
||||||
{
|
|
||||||
test.matrix[i] = (float)i;
|
|
||||||
}
|
|
||||||
|
|
||||||
//t.Pack(test, sendBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
Test::~Test()
|
|
||||||
{
|
|
||||||
for(int i = 0; i < (int)clients.size(); i++)
|
|
||||||
delete clients.at(i);
|
|
||||||
|
|
||||||
server.Stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Test::ProcFunction(CustomNetProtocol& protocol)
|
|
||||||
{
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Test::mainLoop()
|
|
||||||
{
|
|
||||||
WinTimer timer;
|
|
||||||
|
|
||||||
while(1)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Test::PrintOutMessage(ProtocolSet* set)
|
|
||||||
{
|
|
||||||
switch(set->type)
|
|
||||||
{
|
|
||||||
case PackageType_header:
|
|
||||||
break;
|
|
||||||
case PackageType_test:
|
|
||||||
cout <<"Client 2: " << set->Protocol.pTest->textMessage <<endl;
|
|
||||||
for(int i = 0; i < (int)set->Protocol.pTest->numOfFloats; i++)
|
|
||||||
{
|
|
||||||
cout << set->Protocol.pTest->f[i] << ' ' ;
|
|
||||||
}
|
|
||||||
cout << endl;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PackageType_player_pos:
|
|
||||||
//cout << "ID " << set->Protocol.pPlayerPos->ID << endl;
|
|
||||||
for(int i = 0; i < (int)set->Protocol.pPlayerPos->nrOfFloats; i++)
|
|
||||||
{
|
|
||||||
cout << set->Protocol.pPlayerPos->matrix[i] << ' ';
|
|
||||||
}
|
|
||||||
cout << endl;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}*/
|
|
|
@ -1,38 +0,0 @@
|
||||||
#ifndef TEST_CLASS_H
|
|
||||||
#define TEST_CLASS_H
|
|
||||||
/*
|
|
||||||
#include "../../Misc/Utilities.h"
|
|
||||||
#include "../NetworkDependencies/OysterByte.h"
|
|
||||||
#include "../NetworkDependencies/PostBox.h"
|
|
||||||
#include "../NetworkAPI/NetworkClient.h"
|
|
||||||
#include "../NetworkAPI/NetworkServer.h"
|
|
||||||
//#include "../NetworkDependencies/Translator.h"
|
|
||||||
#include "../NetworkAPI/CustomNetProtocol.h"
|
|
||||||
#include "../NetworkDependencies/Protocols.h"
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
class Test
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Test();
|
|
||||||
~Test();
|
|
||||||
|
|
||||||
void mainLoop();
|
|
||||||
|
|
||||||
virtual void ProcFunction(Oyster::Network::CustomNetProtocol& protocol);
|
|
||||||
void PrintOutMessage(Oyster::Network::Protocols::ProtocolSet* set);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::vector<Oyster::Network::NetworkClient*> clients;
|
|
||||||
Oyster::Network::IPostBox<Utility::DynamicMemory::SmartPointer<Oyster::Network::OysterByte>> *recvPostBox;
|
|
||||||
|
|
||||||
//Oyster::Network::Translator t;
|
|
||||||
Oyster::Network::Protocols::ProtocolPlayerPos test;
|
|
||||||
Utility::DynamicMemory::SmartPointer<Oyster::Network::OysterByte> sendBuffer;
|
|
||||||
Utility::DynamicMemory::SmartPointer<Oyster::Network::OysterByte> recvBuffer;
|
|
||||||
|
|
||||||
Oyster::Network::NetworkServer server;
|
|
||||||
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
#endif
|
|
Loading…
Reference in New Issue