mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
Minor cleanup - move reinterpret_cast to jsonNode
This commit is contained in:
parent
55b504792e
commit
461bca73f3
@ -57,9 +57,7 @@ void GlobalLobbyClient::onPacketReceived(const std::shared_ptr<NetworkConnection
|
||||
{
|
||||
boost::mutex::scoped_lock interfaceLock(GH.interfaceMutex);
|
||||
|
||||
// FIXME: find better approach
|
||||
const char * payloadBegin = reinterpret_cast<const char*>(message.data());
|
||||
JsonNode json(payloadBegin, message.size());
|
||||
JsonNode json(message.data(), message.size());
|
||||
|
||||
if (json["type"].String() == "authentication")
|
||||
{
|
||||
|
@ -72,6 +72,10 @@ JsonNode::JsonNode(JsonType Type)
|
||||
setType(Type);
|
||||
}
|
||||
|
||||
JsonNode::JsonNode(const uint8_t *data, size_t datasize)
|
||||
:JsonNode(reinterpret_cast<const char*>(data), datasize)
|
||||
{}
|
||||
|
||||
JsonNode::JsonNode(const char *data, size_t datasize)
|
||||
{
|
||||
JsonParser parser(data, datasize);
|
||||
|
@ -51,6 +51,7 @@ public:
|
||||
JsonNode(JsonType Type = JsonType::DATA_NULL);
|
||||
//Create tree from Json-formatted input
|
||||
explicit JsonNode(const char * data, size_t datasize);
|
||||
explicit JsonNode(const uint8_t * data, size_t datasize);
|
||||
//Create tree from JSON file
|
||||
explicit JsonNode(const JsonPath & fileURI);
|
||||
explicit JsonNode(const std::string & modName, const JsonPath & fileURI);
|
||||
|
@ -129,8 +129,7 @@ void LobbyServer::onDisconnected(const std::shared_ptr<NetworkConnection> & conn
|
||||
void LobbyServer::onPacketReceived(const std::shared_ptr<NetworkConnection> & connection, const std::vector<uint8_t> & message)
|
||||
{
|
||||
// FIXME: find better approach
|
||||
const char * payloadBegin = reinterpret_cast<const char*>(message.data());
|
||||
JsonNode json(payloadBegin, message.size());
|
||||
JsonNode json(message.data(), message.size());
|
||||
|
||||
if (json["type"].String() == "sendChatMessage")
|
||||
return receiveSendChatMessage(connection, json);
|
||||
|
Loading…
Reference in New Issue
Block a user