diff --git a/Code/Network/NetworkDependencies/OysterByte.cpp b/Code/Network/NetworkDependencies/OysterByte.cpp index 99c88d44..ec87a5f6 100644 --- a/Code/Network/NetworkDependencies/OysterByte.cpp +++ b/Code/Network/NetworkDependencies/OysterByte.cpp @@ -109,6 +109,25 @@ OysterByte::operator unsigned char*() return byteArray; } +OysterByte& OysterByte::operator +=(const OysterByte& obj) +{ + int newSize = this->size + obj.size; + + if(newSize >= (int)capacity) + { + IncreaseCapacity(this->size); + } + + for(int i = size, j = 0; i < newSize; i++, j++) + { + this->byteArray[i] = obj.byteArray[j]; + } + + this->size = newSize; + + return *this; +} + ///////////// // Private // ///////////// diff --git a/Code/Network/NetworkDependencies/OysterByte.h b/Code/Network/NetworkDependencies/OysterByte.h index e525095b..4f6f4557 100644 --- a/Code/Network/NetworkDependencies/OysterByte.h +++ b/Code/Network/NetworkDependencies/OysterByte.h @@ -40,6 +40,8 @@ namespace Oyster operator const char*(); operator unsigned char*(); + OysterByte& operator +=(const OysterByte& obj); + private: //Expands the byteArray void IncreaseCapacity(unsigned int cap); diff --git a/Code/Network/OysterNetworkClient/ClientMain.cpp b/Code/Network/OysterNetworkClient/ClientMain.cpp index a04294c6..2d008356 100644 --- a/Code/Network/OysterNetworkClient/ClientMain.cpp +++ b/Code/Network/OysterNetworkClient/ClientMain.cpp @@ -41,11 +41,21 @@ int main() } //client.SetRecieverObject(proc, NetworkProtocolCallbackType_Function); + OysterByte bytes, bytes2, bytes3; + bytes.AddSize(4); + bytes2.AddSize(5); + strcpy_s(bytes, 5, "asda"); + strcpy_s(bytes2, 6, "asdab"); + bytes += bytes2; + bytes += bytes; + bytes += bytes; + bytes3 = bytes; + cout << "Done" << endl; while(1) { - + } ShutdownWinSock(); diff --git a/Code/Network/OysterNetworkServer/ServerMain.cpp b/Code/Network/OysterNetworkServer/ServerMain.cpp index 1ad3c725..48e36e8e 100644 --- a/Code/Network/OysterNetworkServer/ServerMain.cpp +++ b/Code/Network/OysterNetworkServer/ServerMain.cpp @@ -1,15 +1,22 @@ #include #include #include +#include #include "../NetworkDependencies/WinsockFunctions.h" #include "../NetworkAPI/NetworkServer.h" using namespace Oyster::Network; using namespace std; +vector clients; +std::mutex m; + void proc(NetworkClient client) { cout << "Hej" << endl; + m.lock(); + clients.push_back(client); + m.unlock(); } int main() @@ -38,9 +45,14 @@ int main() while(1) { - + Sleep(1000); + m.lock(); + cout << clients.size() << endl; + m.unlock(); + break; } + server.Stop(); system("pause");