发帖
充值
 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
首页问答专区问一下有没有对接易语言的例子

问一下有没有对接易语言的例子

0
回复
2636
查看
[ 复制链接 ]

1

主题

16

回帖

255

积分

中级会员

积分
255
2022-5-29 04:27:06 显示全部楼层 阅读模式
问一下有没有对接易语言的例子,测试失败。

  1. local ws = nil

  2. function wLog(text)
  3. print(text)
  4. toast(text,0,0,20)
  5. end

  6. function onOpened(handle)
  7. ws = handle
  8. print("连接上服务器")
  9. end

  10. function reConnect()
  11. ws = nil
  12. wLog("断开连接,3秒后重连")
  13. setTimer(function()
  14. startWebSocket("ws://192.168.2.105:5586",
  15. onOpened,onClosed,onError,onRecv)
  16. end,3000)
  17. end

  18. function onClosed(handle)
  19. reConnect()
  20. end

  21. function onError(handle)
  22. reConnect()
  23. end

  24. function onRecv(handle,message)
  25. local text = "消息:"..message
  26. wLog(text)
  27. end

  28. local handle = startWebSocket("ws://192.168.2.105:5586",
  29. onOpened,onClosed,onError,onRecv)

  30. if handle ~= nil then
  31. local tick = 1
  32. while true do
  33. if ws ~= nil then
  34. sendWebSocket(ws,string.format("hello:%d",tick))
  35. tick = tick + 1
  36. end
  37. sleep(100)
  38. end
  39. end
复制代码


使用道具
举报
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则