diff --git a/src/internal/sio_packet.cpp b/src/internal/sio_packet.cpp index 4b810987..3d31cf13 100644 --- a/src/internal/sio_packet.cpp +++ b/src/internal/sio_packet.cpp @@ -134,6 +134,10 @@ namespace sio { return int_message::create(value.GetInt64()); } + else if (value.IsUint64()) + { + return int_message::create(static_cast(value.GetUint64())); + } else if(value.IsDouble()) { return double_message::create(value.GetDouble()); @@ -176,14 +180,14 @@ namespace sio } return ptr; } - else if(value.IsBool()) - { - return bool_message::create(value.GetBool()); - } - else if(value.IsNull()) - { - return null_message::create(); - } + else if(value.IsBool()) + { + return bool_message::create(value.GetBool()); + } + else if(value.IsNull()) + { + return null_message::create(); + } return message::ptr(); } diff --git a/test/sio_test.cpp b/test/sio_test.cpp index 3901f05e..bd6d352d 100644 --- a/test/sio_test.cpp +++ b/test/sio_test.cpp @@ -234,3 +234,23 @@ TEST_CASE( "test_packet_parse_4" ) CHECK(array->get_vector()[2]->get_string() == "text"); } + +/* + * Test parsing of UInt64 values. See #174. + */ +TEST_CASE( "test_packet_parse_5" ) +{ + packet p; + bool hasbin = p.parse("42/nsp,1001[\"event\",17657333360744292000]"); + CHECK(!hasbin); + CHECK(p.get_frame() == packet::frame_message); + CHECK(p.get_type() == packet::type_event); + CHECK(p.get_nsp() == "/nsp"); + CHECK(p.get_pack_id() == 1001); + CHECK(p.get_message()->get_flag() == message::flag_array); + REQUIRE(p.get_message()->get_vector().size() == 2); + REQUIRE(p.get_message()->get_vector()[0]->get_flag() == message::flag_string); + CHECK(p.get_message()->get_vector()[0]->get_string() == "event"); + REQUIRE(p.get_message()->get_vector()[1]->get_flag() == message::flag_integer); + CHECK(p.get_message()->get_vector()[1]->get_int() == 17657333360744292000U); +}