Add protocol revision number in protocol hash

This commit is contained in:
Guillaume Meunier
2024-11-10 21:17:08 +01:00
parent 97bacfcd35
commit c5db0258be
3 changed files with 8 additions and 2 deletions
+1 -1
View File
@@ -6,5 +6,5 @@
namespace wivrn
{
using protocol = std::variant<from_headset::packets, to_headset::packets>;
static inline const constinit auto protocol_version = serialization_type_hash<protocol>();
static inline const constinit auto protocol_version = serialization_type_hash<protocol>(protocol_revision);
} // namespace wivrn
+2
View File
@@ -38,6 +38,8 @@ namespace wivrn
// Default port for server to listen, both TCP and UDP
static const int default_port = 9757;
static constexpr int protocol_revision = 0;
enum class device_id : uint8_t
{
HEAD, // /user/head
+5 -1
View File
@@ -882,10 +882,14 @@ struct serialization_traits<data_holder>
};
template <typename T>
constexpr uint64_t serialization_type_hash()
constexpr uint64_t serialization_type_hash(int revision)
{
details::hash_context h;
serialization_traits<T>::type_hash(h);
if (revision)
h.feed(revision);
return h.hash;
}