zbizu
Legendary OT User
Hello.
I'm trying to obtain server info for otclient through Protocol methods.
Example in php: renatorib/otinfo (https://github.com/renatorib/otinfo)
my code is:
The terminal output is:
my question is: how do I obtain string from received userdata?
I don't mind source edits if necessary.
I'm trying to obtain server info for otclient through Protocol methods.
Example in php: renatorib/otinfo (https://github.com/renatorib/otinfo)
my code is:
Lua:
HOST = '127.0.0.1'
PORT = 7171
function sendTestingRequest()
if not HOST then
return
end
local protocol = Protocol.create()
protocol.onConnect = onConnect
protocol.onRecv = onRecv
--protocol.onError = onError
protocol:connect(HOST, PORT)
end
function onConnect(protocol)
-- print in terminal
pinfo(tostring(protocol))
pinfo("connected")
local msg = OutputMessage.create()
msg:addString("\6")
msg:addString("\0")
msg:addString("\255")
msg:addString("\255")
protocol:send(msg)
protocol:recv()
end
function onRecv(message)
pinfo("received")
pinfo(tostring(message))
for k, v in pairs(getmetatable(message)) do
pinfo(k, v)
end
--protocol:disconnect()
end
The terminal output is:
Code:
Loaded module 'test'
> sendTestingRequest()
userdata: 0x04ee9d38
connected
received
userdata: 0x04eea028
__newindex
fieldmethods
__eq
methods
__gc
__index
my question is: how do I obtain string from received userdata?
I don't mind source edits if necessary.