Http

4/3/2024 Unity3d

send http request

functions

functions parameter describe
LuaHandler.Request(data,function) 1.Dictionary

2. lua function

return: requestkey
The data dictionary must contain a 'cmd'

requestkey is string
LuaHandler.CancelRequest(requestkey) requestkey requestkey is string

If the request has been sent, the bottom layer will not push the data to the application interface after receiving the data.

If the data is still not sent successfully, the bottom layer will release the request

example:

local requestkey=''
function Start()
    local dataTable={}
    dataTable['cmd'] = 'LowUse.sendRequest'
    dataTable['xxx'] = 'data'
   requestkey= LuaHandler.Request(dataTable,OnResult)
end
    
function OnResult(jsonstring)
   print(jsonstring) -- LUA: {"code":0,"msg":"success"}
end

function OnDestroy()
    LuaHandler.CancelRequest(requestkey)
end
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Last Updated: Thu, 11 Apr 2024 06:54:22 GMT