17 Commits

Author SHA1 Message Date
014db34116 refactor 2025-02-23 10:35:47 +01:00
d99137d78d yes 2025-02-22 22:51:13 +01:00
3bc1f60531 jsp 2025-02-22 22:32:36 +01:00
992a6eeca0 refactor xmake.lua 2025-02-22 22:10:54 +01:00
8762222e0f add header files for install 2025-02-22 22:05:53 +01:00
c669e459dd refactor xmake.lua 2025-02-18 19:50:59 +01:00
3bc5b50905 refactor: split message classes 2025-02-18 19:40:41 +01:00
66835554f1 enum class field access 2025-02-18 19:33:02 +01:00
e16ad84865 oui 2025-02-18 19:12:51 +01:00
c1e6409c18 idk 2025-02-18 19:12:35 +01:00
3ad18cacf6 add handlers constness 2025-02-18 19:12:16 +01:00
2eab50932f better example 2025-02-18 19:09:40 +01:00
baa52d3baa databuffer 2025-02-18 19:02:33 +01:00
d924685e0c oups 2025-02-18 19:00:59 +01:00
044b12cdec refactor 2025-02-18 19:00:01 +01:00
e39f8de898 better fields access 2025-02-15 12:39:53 +01:00
0b28bde25b test 2025-02-08 20:11:02 +01:00
4 changed files with 7 additions and 49 deletions

View File

@@ -1,10 +0,0 @@
# SimpleProtocolLib
Network engine used to (mainly) communicate with packets
# Integrate with xmake
```lua
add_repositories("persson-repo https://git.ale-pri.com/Persson-dev/xmake-repo.git")
add_requires("splib", { debug = is_mode("debug") })
```

View File

@@ -13,7 +13,6 @@
#include <string> #include <string>
#include <sp/common/VarInt.h> #include <sp/common/VarInt.h>
#include <vector> #include <vector>
#include <map>
namespace sp { namespace sp {
@@ -89,19 +88,6 @@ class DataBuffer {
return *this; return *this;
} }
/**
* \brief Append a map to the buffer by first writing the size
* \param data The map to append
*/
template <typename K, typename V>
DataBuffer& operator<<(const std::map<K, V>& data) {
*this << VarInt{data.size()};
for (const auto& element : data) {
*this << element.first << element.second;
}
return *this;
}
/** /**
* \brief Append an array to the buffer by first writing the size * \brief Append an array to the buffer by first writing the size
* \param data The buffer to append * \param data The buffer to append
@@ -154,23 +140,6 @@ class DataBuffer {
return *this; return *this;
} }
/**
* \brief Read a map (size + data) from the buffer
* \pre The map is assumed to be empty
*/
template <typename K, typename V>
DataBuffer& operator>>(std::map<K, V>& data) {
VarInt mapSize;
*this >> mapSize;
for (std::size_t i = 0; i < mapSize.GetValue(); i++) {
K newKey;
V newValue;
*this >> newKey >> newValue;
data.insert({newKey, newValue});
}
return *this;
}
/** /**
* \brief Read an array from the buffer * \brief Read an array from the buffer
*/ */

View File

@@ -6,8 +6,7 @@
namespace sp { namespace sp {
class PacketHandler; class PacketHandler;
using PacketMessage = Message< using PacketMessage = Message<option::MsgIdType<std::uint8_t>, // add id() operation
option::MsgIdType<std::uint8_t>, // add id() operation
option::ReadOperations, // add read() operation option::ReadOperations, // add read() operation
option::WriteOperations, // add write() operation option::WriteOperations, // add write() operation
option::WriteId, // write id before data option::WriteId, // write id before data

View File

@@ -114,6 +114,6 @@ template <typename TField, typename... TFields>
struct FieldsBuilder<TField, TFields...> { struct FieldsBuilder<TField, TFields...> {
using Type = sp::tuple_cat_t<std::tuple<Field<TField, 0>>, typename FieldsBuilder<TFields...>::Type>; using Type = sp::tuple_cat_t<std::tuple<Field<TField, 0>>, typename FieldsBuilder<TFields...>::Type>;
}; };
} // namespace details } // namespace details
} // namespace sp } // namespace sp