Commit ef291a71 authored by PicassoCT's avatar PicassoCT

This needs some serious thinking. And a vector for rapid downloads...

This needs some serious thinking. And a vector for rapid downloads (games/engines) commands, a vector for downloading map (maps) commands
and a vector for lobby configurations. Then we need methods to apply them.
parent 36e874af
/* This file is part of the Springlobby (GPL v2 or later), see COPYING */
#include "rapidpayloadconfighandler.h"
#include <json/reader.h>
#include <wx/log.h>
void RapidPayloadConfigHandler::RapidPayloadConfigHandler(const std::string& bundleName){};
/*
file bundles/Spring1944/Spring1944-3.00.json:
{
version = 1,
game = "Spring: 1944",
game_version = "3.00",
engine = "SpringRTS",
engine_version = "103.0",
maps = [
{"1944_village_crossing", "v3"),
{"1944_Titan", ""}
],
ai = null,
filter = same format as in sl.conf,
join_channels = ["s44", "s44games", "newbies"]
}
*/
void RapidPayloadConfigHandler::ParseJson(const std::string& jsonstr)
{
wxLogDebug("JSON %s", jsonstr.c_str());
Json::Value js; // will contains the root value after parsing.
Json::Reader reader;
const bool parsingSuccessful = reader.parse(jsonstr, js);
if (!parsingSuccessful) {
wxLogWarning("Invalid json: %s", jsonstr.c_str());
return;
}
if (!js.isObject()) {
m_se->OnServerMessage(stdprintf("Invalid json, object excepted: %s", jsonstr.c_str()));
return;
}
if (js["FAILED"].isObject()) {
m_se->OnServerMessage(js["FAILED"]["msg"].asString());
return;
}
if (js["SAID"].isObject()) {
Json::Value said = js["SAID"];
cfg().Write(wxString::Format("/Channels/%s/lastid", said["chanName"].asString()), said["id"].asInt());
m_se->OnChannelSaid(said["chanName"].asString(), said["userName"].asString(), said["msg"].asString());
return;
}
wxLogWarning("Unknown command received: %s", jsonstr.c_str());
}
......@@ -14,7 +14,7 @@ class RapidPayloadConfigHandler;
class RapidPayloadConfigHandler
{
public:
RapidPayloadConfigHandler(const std::string& jsonPath);
RapidPayloadConfigHandler(const std::string& bundleName);
void ParseJson(const std::string& jsonstr);
private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment