Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copas looping issue while connecting the server #104

Open
pritammore opened this issue Mar 22, 2017 · 0 comments
Open

copas looping issue while connecting the server #104

pritammore opened this issue Mar 22, 2017 · 0 comments

Comments

@pritammore
Copy link

pritammore commented Mar 22, 2017

Hi,
I am new to lua programming and trying to implement Lua-websocket in openwrt as a client.
Was trying to use client copas library but the issue is the script is getting stopped listening server after executing once (i.e. connecting to server, receiving message, sending message). I want the script to always listen the server without any timeout or script halt.
Below is the script

local copas = require'copas'
local websocket = require'websocket'
local json = require('json')
local client = require 'websocket.client'.new()

local ok,err = client:connect('ws://192.168.1.250:8080')
if not ok then
print('could not connect',err)
end

local ap_mac = { command = 'subscribe', channel = 'test' }
local ok = client:send(json.encode(ap_mac))
if ok then
print('msg sent')
else
print('connection closed')
end

local message,opcode = client:receive()
if message then
print('msg',message,opcode)
else
print('connection closed')
end

local replymessage = { command = 'message', message = 'TEST' }
local ok = client:send(json.encode(replymessage))
if ok then
print('msg sent')
else
print('connection closed')
end

copas.loop()

Here copas.loop() is not working.

On openWrt I had installed lua 5.1
Any help would be appreciated.

@pritammore pritammore changed the title copas looping issue while connecting the client copas looping issue while connecting the server Mar 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant