问一下有没有对接易语言的例子,测试失败。
- local ws = nil
- function wLog(text)
- print(text)
- toast(text,0,0,20)
- end
- function onOpened(handle)
- ws = handle
- print("连接上服务器")
- end
- function reConnect()
- ws = nil
- wLog("断开连接,3秒后重连")
- setTimer(function()
- startWebSocket("ws://192.168.2.105:5586",
- onOpened,onClosed,onError,onRecv)
- end,3000)
- end
- function onClosed(handle)
- reConnect()
- end
- function onError(handle)
- reConnect()
- end
- function onRecv(handle,message)
- local text = "消息:"..message
- wLog(text)
- end
- local handle = startWebSocket("ws://192.168.2.105:5586",
- onOpened,onClosed,onError,onRecv)
- if handle ~= nil then
- local tick = 1
- while true do
- if ws ~= nil then
- sendWebSocket(ws,string.format("hello:%d",tick))
- tick = tick + 1
- end
- sleep(100)
- end
- end
复制代码
|