feat: Унифицирован формат сообщений
This commit is contained in:
@@ -45,9 +45,7 @@ class PyG2O
|
||||
|
||||
function _send(data, uuid = "none")
|
||||
{
|
||||
if (uuid != "none")
|
||||
data["uuid"] <- uuid;
|
||||
|
||||
data["uuid"] <- uuid;
|
||||
_connection.send(JSON.dump_ansi(data, 2));
|
||||
}
|
||||
|
||||
@@ -56,7 +54,7 @@ class PyG2O
|
||||
if (!_silent)
|
||||
print("[PyG2O] Successfully connected to " + url);
|
||||
|
||||
_send({"init_temp_tokens": _clientTokens});
|
||||
_send({"event": "init_temp_tokens", "token": _clientTokens});
|
||||
}
|
||||
|
||||
function _onClose(url, message)
|
||||
@@ -98,7 +96,7 @@ class PyG2O
|
||||
|
||||
addEventHandler("onPlayerJoin", function(playerid){
|
||||
local new_token = _globalInstance.generateClientPassword();
|
||||
_globalInstance._send({"create_temp_token": new_token})
|
||||
_globalInstance._send({"event": "create_temp_token", "token": new_token})
|
||||
_clientTokens[playerid] <- new_token;
|
||||
|
||||
local packet = Packet();
|
||||
@@ -108,6 +106,6 @@ addEventHandler("onPlayerJoin", function(playerid){
|
||||
});
|
||||
|
||||
addEventHandler("onPlayerDisconnect", function(playerid, reason){
|
||||
_globalInstance._send({"remove_temp_token": _clientTokens[playerid]});
|
||||
_globalInstance._send({"event": "remove_temp_token", "token": _clientTokens[playerid]});
|
||||
delete _clientTokens[playerid];
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user