fix: Исправлено взаимодействие с бэкендом в контексте приема сообщений и управления токенами
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
_globalInstance <- -1;
|
_globalInstance <- -1;
|
||||||
local _clientTokens = [];
|
local _clientTokens = {};
|
||||||
|
|
||||||
class PyG2O
|
class PyG2O
|
||||||
{
|
{
|
||||||
@@ -76,7 +76,7 @@ class PyG2O
|
|||||||
!("data" in request))
|
!("data" in request))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_message_call.bindenv(this)(request["data"]);
|
_message_call.bindenv(this)(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateClientPassword()
|
function generateClientPassword()
|
||||||
@@ -97,7 +97,7 @@ class PyG2O
|
|||||||
addEventHandler("onPlayerJoin", function(playerid){
|
addEventHandler("onPlayerJoin", function(playerid){
|
||||||
local new_token = _globalInstance.generateClientPassword();
|
local new_token = _globalInstance.generateClientPassword();
|
||||||
_globalInstance._send({"create_temp_token": new_token})
|
_globalInstance._send({"create_temp_token": new_token})
|
||||||
_clientTokens[playerid] = new_token;
|
_clientTokens[playerid] <- new_token;
|
||||||
|
|
||||||
local packet = Packet();
|
local packet = Packet();
|
||||||
packet.writeUInt8(250);
|
packet.writeUInt8(250);
|
||||||
@@ -107,4 +107,5 @@ addEventHandler("onPlayerJoin", function(playerid){
|
|||||||
|
|
||||||
addEventHandler("onPlayerDisconnect", function(playerid, reason){
|
addEventHandler("onPlayerDisconnect", function(playerid, reason){
|
||||||
_globalInstance._send({"remove_temp_token": _clientTokens[playerid]});
|
_globalInstance._send({"remove_temp_token": _clientTokens[playerid]});
|
||||||
|
delete _clientTokens[playerid];
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user