IXWebSocket/luarocks/echo_client.lua

31 lines
596 B
Lua
Raw Permalink Normal View History

2020-04-28 22:15:43 -07:00
--
-- make luarocks && (cd luarocks ; ../build/luarocks/luarocks)
--
2020-05-03 19:09:23 -07:00
-- ... git push test with ssh key
--
2020-04-28 22:15:43 -07:00
local webSocket = WebSocket.new()
2020-04-20 23:02:23 -07:00
webSocket:setUrl("ws://localhost:8008")
print("Url: " .. webSocket:getUrl())
2020-04-20 23:02:23 -07:00
2020-04-28 22:15:43 -07:00
-- Start the background thread
webSocket:start()
2020-04-20 23:02:23 -07:00
2020-04-28 22:15:43 -07:00
local i = 0
while true
do
2020-04-28 22:15:43 -07:00
print("Sending message...")
webSocket:send("msg_" .. tostring(i));
i = i + 1
print("Waiting 1s...")
webSocket:sleep(1000)
2020-04-28 22:15:43 -07:00
if webSocket:hasMessage() then
local msg = webSocket:getMessage()
print("Received: " .. msg)
webSocket:popMessage()
end
end