Added json reader utilities and implemented json reader functions to dem, net, and svc types
This commit is contained in:
@ -28,17 +28,24 @@ namespace NetHandlers
|
||||
|
||||
bool SVC_UserMessage_JsonRead_Internal(JsonRead& jsonbuf, SourceGameContext& context, NetMsg::SVC_UserMessage* data)
|
||||
{
|
||||
return true;
|
||||
base::JsonReaderObject reader = jsonbuf.ParseObject();
|
||||
assert(!reader.HasReadError());
|
||||
data->msgType = reader.ReadUInt32("msgType");
|
||||
data->dataLengthInBits = reader.ReadUInt32("dataLengthInBits");
|
||||
data->data.reset(new uint8_t[math::BitsToBytes(data->dataLengthInBits)]);
|
||||
reader.ReadBits("data", data->data.get(), data->dataLengthInBits);
|
||||
return !reader.HasReadError();
|
||||
}
|
||||
|
||||
bool SVC_UserMessage_JsonWrite_Internal(JsonWrite& jsonbuf, const SourceGameContext& context, NetMsg::SVC_UserMessage* data)
|
||||
{
|
||||
jsonbuf.StartObject("svc_usermessage");
|
||||
jsonbuf.Reset();
|
||||
jsonbuf.StartObject();
|
||||
jsonbuf.WriteUInt32("msgType", data->msgType);
|
||||
jsonbuf.WriteUInt32("dataLengthInBits", data->dataLengthInBits);
|
||||
jsonbuf.WriteBits("data", data->data.get(), data->dataLengthInBits);
|
||||
jsonbuf.EndObject();
|
||||
return true;
|
||||
return jsonbuf.IsComplete();
|
||||
}
|
||||
|
||||
void SVC_UserMessage_ToString_Internal(std::ostringstream& out, NetMsg::SVC_UserMessage* data)
|
||||
|
Reference in New Issue
Block a user