Hiho,…atm I’m trying to cross-compile my testgame to windows using mingw. Most of the stuff compiles, but one thing does not:
/var/sample/src/game/serverObjects/MasterServerCommunication.cpp: In member function 'void MasterServerCommunication::HandleBeginFrame(Urho3D::StringHash, Urho3D::VariantMap&)':
/var/sample/src/game/serverObjects/MasterServerCommunication.cpp:46:40: error: 'const class Urho3D::JSONValue' has no member named 'GetObject'; did you mean 'GetObjectA'?
JSONObject data = root.GetObject();
^~~~~~~~~
GetObjectA
The thing is, I use identical code at other classes without a problem
JSONFile jsonFile(context_);
jsonFile.FromString(String(json.c_str()));
const JSONValue root = jsonFile.GetRoot();
JSONObject data = root.GetObject();
I found the suggestion strange ‘did you mean GetObjectA’. Just out of curiosity I tried GetObjectA() and it compiled!? I’m actually not sure what I made wrong. Is that a known behaviour and what would be a keyword to search for. I refuse to use an #ifdef MINGW and use GetObjectA (for now).
(btw, on linux it compiles with GetObject as intended)
Here the complete cpp-file. Maybe someone see something, beside ugly code:
#include "MasterServerCommunication.h"
//#include "Server/SaalisServer.h"
//#include <game/gameObjects/SaalisServer.h>
#include <Urho3D/Scene/Scene.h>
#include <zmq_addon.hpp>
#include <game/SaalisEvents.h>
#include <game/serverObjects/SaalisServer.h>
#include <Urho3D/Resource/JSONFile.h>
//#include <Urho3D/Resource/JSONValue.h>
MasterServerCommunication::MasterServerCommunication(Context* context)
: Object(context),
state_(FLAG_SEND_READY_INFO)
{
saalisServer = GetSubsystem<SaalisServer>();
SubscribeToEvent(E_BEGINFRAME,URHO3D_HANDLER(MasterServerCommunication,HandleBeginFrame));
}
void MasterServerCommunication::Connect(const String &masterUrl, int masterPort)
{
reqSocket_ = zmq::socket_t(ctx, zmq::socket_type::req);
reqSocket_.connect( (String("tcp://")+masterUrl+":"+String(masterPort)).CString());
}
void MasterServerCommunication::HandleBeginFrame(StringHash eventType, VariantMap &eventData)
{
if (state_ == FLAG_SEND_READY_INFO){
msg.clear();
msg.addstr(saalisServer->GetServerName().CString());
msg.addstr( ((String("ready,"+saalisServer->GetServerName()+",")+String(saalisServer->MatchSlotsLeft()))).CString()) ;
msg.send(reqSocket_);
state_ = FLAG_RECEIVE_REQUEST;
}
else if (state_ == FLAG_RECEIVE_REQUEST){
bool success = msg.recv(reqSocket_,ZMQ_NOBLOCK);
if (success){
auto type = msg.popstr();
if (type == "create_match"){
auto json = msg.popstr();
JSONFile jsonFile(context_);
jsonFile.FromString(String(json.c_str()));
const JSONValue root = jsonFile.GetRoot();
JSONObject data = root.GetObjectA();
using namespace MasterEventCreateMatch;
VariantMap masterEventData;
String matchId = data["match_id"].GetString();
String token = data["token"].GetString();
auto jsonUsers = data["users"].GetArray();
StringVector users;
for (auto u : jsonUsers){
users.Push(u.GetString());
}
if (saalisServer->IsNewSessionAllowed()){
saalisServer->CreateNewSession(matchId,token,users);
// TODO: send via pubsubcom about creation
// msg.clear();
// msg.addstr(saalisServer->GetServerName().CString());
// msg.addstr((String("created-match,"+saalisServer->GetServerName()+",")+matchId).CString());
// msg.send(reqSocket_);
} else {
// TODO: send via pubsubcom about fail in creation
// msg.clear();
// msg.addstr(saalisServer->GetServerName().CString());
// msg.addstr((String("not_created-match,"+saalisServer->GetServerName()+",")+matchId).CString());
// msg.send(reqSocket_);
}
if (saalisServer->IsNewSessionAllowed()){
state_=FLAG_SEND_READY_INFO;
} else {
state_=FLAG_WAIT_FOR_RESOURCES;
}
}
}
}
}
void MasterServerCommunication::RegisterObject(Context* context) {
}