Add parseJson and clientWorld functions to LuaBindings
This commit is contained in:
parent
330fc938f3
commit
868216a992
@ -113,6 +113,7 @@ LuaCallbacks LuaBindings::makeUtilityCallbacks() {
|
||||
callbacks.registerCallback("logWarn", UtilityCallbacks::logWarn);
|
||||
callbacks.registerCallback("logError", UtilityCallbacks::logError);
|
||||
callbacks.registerCallback("setLogMap", UtilityCallbacks::setLogMap);
|
||||
callbacks.registerCallback("parseJson", UtilityCallbacks::parseJson);
|
||||
callbacks.registerCallback("printJson", UtilityCallbacks::printJson);
|
||||
callbacks.registerCallback("print", UtilityCallbacks::print);
|
||||
callbacks.registerCallback("interpolateSinEase", UtilityCallbacks::interpolateSinEase);
|
||||
@ -192,6 +193,10 @@ void LuaBindings::UtilityCallbacks::setLogMap(String const& key, String const& v
|
||||
LogMap::set(key, formatLua(value, args));
|
||||
}
|
||||
|
||||
Json LuaBindings::UtilityCallbacks::parseJson(String const& str) {
|
||||
return Json::parse(str);
|
||||
}
|
||||
|
||||
String LuaBindings::UtilityCallbacks::printJson(Json const& arg, Maybe<int> pretty) {
|
||||
return arg.repr(pretty.value());
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ namespace LuaBindings {
|
||||
void logWarn(String const& str, LuaVariadic<LuaValue> const& args);
|
||||
void logError(String const& str, LuaVariadic<LuaValue> const& args);
|
||||
void setLogMap(String const& key, String const& value, LuaVariadic<LuaValue> const& args);
|
||||
Json parseJson(String const& str);
|
||||
String printJson(Json const& arg, Maybe<int> pretty);
|
||||
String print(LuaValue const& arg);
|
||||
LuaValue interpolateSinEase(LuaEngine& engine, double offset, LuaValue const& value1, LuaValue const& value2);
|
||||
|
@ -22,6 +22,7 @@ LuaCallbacks LuaBindings::makeUniverseServerCallbacks(UniverseServer* universe)
|
||||
callbacks.registerCallbackWithSignature<StringList>("activeWorlds", bind(UniverseServerCallbacks::activeWorlds, universe));
|
||||
callbacks.registerCallbackWithSignature<RpcThreadPromise<Json>, String, String, LuaVariadic<Json>>("sendWorldMessage", bind(UniverseServerCallbacks::sendWorldMessage, universe, _1, _2, _3));
|
||||
callbacks.registerCallbackWithSignature<void, ConnectionId, String, Json>("sendPacket", bind(UniverseServerCallbacks::sendPacket, universe, _1, _2, _3));
|
||||
callbacks.registerCallbackWithSignature<String, ConnectionId>("clientWorld", bind(UniverseServerCallbacks::clientWorld, universe, _1));
|
||||
|
||||
return callbacks;
|
||||
}
|
||||
@ -133,4 +134,8 @@ void LuaBindings::UniverseServerCallbacks::sendPacket(UniverseServer* universe,
|
||||
universe->sendPacket(clientId, packet);
|
||||
}
|
||||
|
||||
String LuaBindings::UniverseServerCallbacks::clientWorld(UniverseServer* universe, ConnectionId clientId) {
|
||||
return printWorldId(universe->clientWorld(clientId));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ namespace LuaBindings {
|
||||
StringList activeWorlds(UniverseServer* universe);
|
||||
RpcThreadPromise<Json> sendWorldMessage(UniverseServer* universe, String const& worldId, String const& message, LuaVariadic<Json> args);
|
||||
void sendPacket(UniverseServer* universe, ConnectionId clientId, String const& packetTypeName, Json const& args);
|
||||
String clientWorld(UniverseServer* universe, ConnectionId clientId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user