2022-03-27 14:49:41 +08:00
|
|
|
local ServerPlayer = Player:subclass("ServerPlayer")
|
2022-03-25 12:28:07 +08:00
|
|
|
|
2022-03-27 14:49:41 +08:00
|
|
|
function ServerPlayer:initialize(_self)
|
|
|
|
Player.initialize(self)
|
|
|
|
self.serverplayer = _self
|
2022-03-30 14:14:40 +08:00
|
|
|
|
|
|
|
self.next = nil
|
|
|
|
|
|
|
|
-- Below are for doBroadcastRequest
|
|
|
|
self.request_data = ""
|
|
|
|
self.client_reply = ""
|
|
|
|
self.default_reply = ""
|
|
|
|
self.reply_ready = false
|
2022-03-27 14:49:41 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function ServerPlayer:getId()
|
|
|
|
return self.serverplayer:getId()
|
|
|
|
end
|
|
|
|
|
2022-03-28 22:24:30 +08:00
|
|
|
function ServerPlayer:doNotify(command, jsonData)
|
|
|
|
self.serverplayer:doNotify(command, jsonData)
|
|
|
|
end
|
|
|
|
|
|
|
|
function ServerPlayer:doRequest(command, jsonData, timeout)
|
2022-03-30 14:14:40 +08:00
|
|
|
timeout = timeout or self.room.timeout
|
|
|
|
self.client_reply = ""
|
|
|
|
self.reply_ready = false
|
2022-03-28 22:24:30 +08:00
|
|
|
self.serverplayer:doRequest(command, jsonData, timeout)
|
|
|
|
end
|
|
|
|
|
2022-03-30 14:14:40 +08:00
|
|
|
function ServerPlayer:waitForReply(timeout)
|
|
|
|
local result = ""
|
|
|
|
if timeout == nil then
|
|
|
|
result = self.serverplayer:waitForReply()
|
|
|
|
else
|
|
|
|
result = self.serverplayer:waitForReply(timeout)
|
|
|
|
end
|
|
|
|
self.request_data = ""
|
|
|
|
self.client_reply = result
|
|
|
|
if result ~= "" then self.reply_ready = true end
|
|
|
|
return result
|
|
|
|
end
|
|
|
|
|
2022-03-27 14:49:41 +08:00
|
|
|
return ServerPlayer
|