diff --git a/TODO b/TODO index d943f55..ea1d314 100644 --- a/TODO +++ b/TODO @@ -6,6 +6,4 @@ handle ReceiveDataArray errors for windows revamped BitConverter class new StringConverter class -implement close() in TcpClientWindows - implement ConfigReader methods \ No newline at end of file diff --git a/TestsVS/Tests/Release/Tests.tlog/CL.read.1.tlog b/TestsVS/Tests/Release/Tests.tlog/CL.read.1.tlog index 833e1ce..047a462 100644 Binary files a/TestsVS/Tests/Release/Tests.tlog/CL.read.1.tlog and b/TestsVS/Tests/Release/Tests.tlog/CL.read.1.tlog differ diff --git a/TestsVS/Tests/Release/Tests.tlog/link.command.1.tlog b/TestsVS/Tests/Release/Tests.tlog/link.command.1.tlog index 46b134b..62783be 100644 Binary files a/TestsVS/Tests/Release/Tests.tlog/link.command.1.tlog and b/TestsVS/Tests/Release/Tests.tlog/link.command.1.tlog differ diff --git a/TestsVS/Tests/Release/Tests.tlog/link.read.1.tlog b/TestsVS/Tests/Release/Tests.tlog/link.read.1.tlog index 46b134b..7ed46ee 100644 Binary files a/TestsVS/Tests/Release/Tests.tlog/link.read.1.tlog and b/TestsVS/Tests/Release/Tests.tlog/link.read.1.tlog differ diff --git a/TestsVS/Tests/Release/Tests.tlog/link.read.4.tlog b/TestsVS/Tests/Release/Tests.tlog/link.read.4.tlog deleted file mode 100644 index 46b134b..0000000 --- a/TestsVS/Tests/Release/Tests.tlog/link.read.4.tlog +++ /dev/null @@ -1 +0,0 @@ -ÿþ \ No newline at end of file diff --git a/TestsVS/Tests/Release/Tests.tlog/link.write.1.tlog b/TestsVS/Tests/Release/Tests.tlog/link.write.1.tlog index 46b134b..33fb381 100644 Binary files a/TestsVS/Tests/Release/Tests.tlog/link.write.1.tlog and b/TestsVS/Tests/Release/Tests.tlog/link.write.1.tlog differ diff --git a/TestsVS/Tests/Release/Tests.tlog/unsuccessfulbuild b/TestsVS/Tests/Release/Tests.tlog/unsuccessfulbuild deleted file mode 100644 index e69de29..0000000 diff --git a/TestsVS/Tests/Tests.cpp b/TestsVS/Tests/Tests.cpp index bde0d81..c73c4dc 100644 --- a/TestsVS/Tests/Tests.cpp +++ b/TestsVS/Tests/Tests.cpp @@ -4,9 +4,10 @@ int main() { - byte *bytes = Utility::BitConverter::FromUint8(20); - std::cout << Utility::BitConverter::ToUint8(bytes, 0) << std::endl; - getchar(); + std::vector bytes = Utility::BitConverter::FromInt32(50000); + int32 integer = Utility::BitConverter::ToInt32(bytes); + std::cout << integer << std::endl; + std::cin.get(); return 0; } diff --git a/VoidNetVS/Release/Tests.iobj b/VoidNetVS/Release/Tests.iobj index 774d6c9..167e559 100644 Binary files a/VoidNetVS/Release/Tests.iobj and b/VoidNetVS/Release/Tests.iobj differ diff --git a/VoidNetVS/Release/Tests.ipdb b/VoidNetVS/Release/Tests.ipdb index 6b09d0f..2157de3 100644 Binary files a/VoidNetVS/Release/Tests.ipdb and b/VoidNetVS/Release/Tests.ipdb differ diff --git a/VoidNetVS/VoidNetVS/Release/VoidNetVS.tlog/CL.command.1.tlog b/VoidNetVS/VoidNetVS/Release/VoidNetVS.tlog/CL.command.1.tlog index 7f2cd02..56f8723 100644 Binary files a/VoidNetVS/VoidNetVS/Release/VoidNetVS.tlog/CL.command.1.tlog and b/VoidNetVS/VoidNetVS/Release/VoidNetVS.tlog/CL.command.1.tlog differ diff --git a/VoidNetVS/VoidNetVS/Release/VoidNetVS.tlog/CL.read.1.tlog b/VoidNetVS/VoidNetVS/Release/VoidNetVS.tlog/CL.read.1.tlog index 1881819..ffcc19c 100644 Binary files a/VoidNetVS/VoidNetVS/Release/VoidNetVS.tlog/CL.read.1.tlog and b/VoidNetVS/VoidNetVS/Release/VoidNetVS.tlog/CL.read.1.tlog differ diff --git a/VoidNetVS/VoidNetVS/Release/VoidNetVS.tlog/CL.write.1.tlog b/VoidNetVS/VoidNetVS/Release/VoidNetVS.tlog/CL.write.1.tlog index 3ac0ee4..90d5000 100644 Binary files a/VoidNetVS/VoidNetVS/Release/VoidNetVS.tlog/CL.write.1.tlog and b/VoidNetVS/VoidNetVS/Release/VoidNetVS.tlog/CL.write.1.tlog differ diff --git a/VoidNetVS/VoidNetVS/Release/VoidNetVS.tlog/Lib.read.1.tlog b/VoidNetVS/VoidNetVS/Release/VoidNetVS.tlog/Lib.read.1.tlog index 77825b3..7743a89 100644 Binary files a/VoidNetVS/VoidNetVS/Release/VoidNetVS.tlog/Lib.read.1.tlog and b/VoidNetVS/VoidNetVS/Release/VoidNetVS.tlog/Lib.read.1.tlog differ diff --git a/VoidNetVS/VoidNetVS/Release/VoidNetVS.tlog/lib.command.1.tlog b/VoidNetVS/VoidNetVS/Release/VoidNetVS.tlog/lib.command.1.tlog index de31f73..f50ac56 100644 Binary files a/VoidNetVS/VoidNetVS/Release/VoidNetVS.tlog/lib.command.1.tlog and b/VoidNetVS/VoidNetVS/Release/VoidNetVS.tlog/lib.command.1.tlog differ diff --git a/VoidNetVS/VoidNetVS/Release/VoidNetVS.tlog/unsuccessfulbuild b/VoidNetVS/VoidNetVS/Release/VoidNetVS.tlog/unsuccessfulbuild deleted file mode 100644 index e69de29..0000000 diff --git a/VoidNetVS/VoidNetVS/VoidNetVS.vcxproj b/VoidNetVS/VoidNetVS/VoidNetVS.vcxproj index cae03af..1eef0c8 100644 --- a/VoidNetVS/VoidNetVS/VoidNetVS.vcxproj +++ b/VoidNetVS/VoidNetVS/VoidNetVS.vcxproj @@ -42,6 +42,7 @@ + true @@ -51,7 +52,6 @@ - diff --git a/VoidNetVS/VoidNetVS/VoidNetVS.vcxproj.filters b/VoidNetVS/VoidNetVS/VoidNetVS.vcxproj.filters index 359ffbc..c6ec425 100644 --- a/VoidNetVS/VoidNetVS/VoidNetVS.vcxproj.filters +++ b/VoidNetVS/VoidNetVS/VoidNetVS.vcxproj.filters @@ -83,7 +83,7 @@ src - + src diff --git a/include/Defs.hpp b/include/Defs.hpp index c858595..24b31c7 100644 --- a/include/Defs.hpp +++ b/include/Defs.hpp @@ -187,8 +187,8 @@ enum ConnectionCode enum InternalTags { - CONNECT = 65534, - DISCONNECT = 65535, + CONNECT = 254, + DISCONNECT = 255, }; #endif // DEFS_HPP \ No newline at end of file diff --git a/include/NetworkBuffer.hpp b/include/NetworkBuffer.hpp index 30ccaa6..f228f6a 100644 --- a/include/NetworkBuffer.hpp +++ b/include/NetworkBuffer.hpp @@ -15,7 +15,7 @@ struct NetworkBuffer NetworkBuffer(); ~NetworkBuffer(); - std::vector header = Utility::BitConverter::FromUint32(8); // contains the size of the body + std::vector header; // size must always be 8 std::vector body; }; diff --git a/include/Utility.hpp b/include/Utility.hpp index 738a0c1..2d56b4a 100644 --- a/include/Utility.hpp +++ b/include/Utility.hpp @@ -54,13 +54,14 @@ struct Utility static const std::string &ToString(int16 value); static const std::string &ToString(int32 value); static const std::string &ToString(int64 value); + static const std::string &ToString(const std::vector &bytes); static const std::string &ToString(const std::vector &bytes, uint16 start_index = 0, uint16 lenght = 0); }; struct ConfigReader { - const void ReadConfig(const std::string &file_name); + void ReadConfig(const std::string &file_name); const std::map &ReadNodes(); const std::string &operator[](uint16 index); diff --git a/src/TcpClientWindows.cpp b/src/TcpClientWindows.cpp index 057cf76..1d207ee 100644 --- a/src/TcpClientWindows.cpp +++ b/src/TcpClientWindows.cpp @@ -75,8 +75,8 @@ void TcpClient::Shutdown() { NetworkMessage message; message.sender = id; - message.distribution_mode = Server; - message.tag = DISCONNECT; + message.distribution_mode = static_cast(Server); + message.tag = static_cast(DISCONNECT); SendMessage(message); uint16 code = closesocket(tcp_socket); if (code == SOCKET_ERROR) diff --git a/src/TcpServerWindows.cpp b/src/TcpServerWindows.cpp index 322fe2d..8b182ae 100644 --- a/src/TcpServerWindows.cpp +++ b/src/TcpServerWindows.cpp @@ -73,9 +73,8 @@ void TcpServer::Shutdown() { for (std::vector::iterator it = clients.begin(); it != clients.end(); ++it) { - TcpClient client = *it; - client.Shutdown(); - clients.erase(std::find(clients.begin(), clients.end(), client)); + (*it).Shutdown(); + clients.erase(it); } } @@ -113,7 +112,7 @@ void TcpServer::accept_connections(TcpServer *server) std::cerr << WSAGetLastError() << std::endl; closesocket(server->server_tcp_socket); WSACleanup(); - server->running = false; + server->running = false; // if we cant accept a connection idk if we should stop the server or not mh break; } diff --git a/src/Utility.cpp b/src/Utility.cpp index 1dbe2a1..3f3b7cb 100644 --- a/src/Utility.cpp +++ b/src/Utility.cpp @@ -98,65 +98,70 @@ int64 Utility::BitConverter::ToInt64(const std::vector & bytes, uint16 sta const std::string & Utility::StringConverter::ToString(bool value) { - // TODO: insert return statement here + return std::string(); } const std::string & Utility::StringConverter::ToString(uint8 value) { - // TODO: insert return statement here + return std::string(); } const std::string & Utility::StringConverter::ToString(uint16 value) { - // TODO: insert return statement here + return std::string(); } const std::string & Utility::StringConverter::ToString(uint32 value) { - // TODO: insert return statement here + return std::string(); } const std::string & Utility::StringConverter::ToString(uint64 value) { - // TODO: insert return statement here + return std::string(); } const std::string & Utility::StringConverter::ToString(int8 value) { - // TODO: insert return statement here + return std::string(); } const std::string & Utility::StringConverter::ToString(int16 value) { - // TODO: insert return statement here + return std::string(); } const std::string & Utility::StringConverter::ToString(int32 value) { - // TODO: insert return statement here + return std::string(); } const std::string & Utility::StringConverter::ToString(int64 value) { - // TODO: insert return statement here + return std::string(); +} + +const std::string & Utility::StringConverter::ToString(const std::vector& bytes) +{ + return std::string(); } const std::string & Utility::StringConverter::ToString(const std::vector & bytes, uint16 start_index, uint16 lenght) { - // TODO: insert return statement here + return std::string(); } -const void Utility::ConfigReader::ReadConfig(const std::string & file_name) +void Utility::ConfigReader::ReadConfig(const std::string & file_name) { - return void(); + } const std::map& Utility::ConfigReader::ReadNodes() { - // TODO: insert return statement here + return std::map(); } const std::string & Utility::ConfigReader::operator[](uint16 index) { - // TODO: insert return statement here + return std::string(); }