Skip to content
This repository was archived by the owner on Jun 1, 2021. It is now read-only.

Commit 05c91de

Browse files
committed
fix some global var access (thanks to lualint)
1 parent 07516d5 commit 05c91de

File tree

7 files changed

+15
-12
lines changed

7 files changed

+15
-12
lines changed

ludent.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env sh
2+
ludent $(find . -name "*.lua")

spec/client_ev_spec.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ describe(
159159
wsc:on_error(async(function(ws,err)
160160
assert.is_same(ws,wsc)
161161
if socket.tcp6 then
162-
assert.is_equal(err,'host or service not provided, or not known')
162+
assert.is_equal(err,'host or service not provided, or not known')
163163
else
164164
assert.is_equal(err,'host not found')
165165
end

src/websocket/client_copas.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ local new = function(ws)
1111
self.sock_connect = function(self,host,port)
1212
self.sock = socket.tcp()
1313
if ws.timeout ~= nil then
14-
sock:settimeout(ws.timeout)
14+
self.sock:settimeout(ws.timeout)
1515
end
1616
local _,err = copas.connect(self.sock,host,port)
1717
if err and err ~= 'already connected' then

src/websocket/client_ev.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@ local ev = function(ws)
9696
on_close(true,code or 1005,reason)
9797
end,handle_socket_err)
9898
else
99-
on_close(true,code or 1005,reason)
99+
on_close(true,1005,'')
100100
end
101101
end
102102
end
103103

104104
self.send = function(_,message,opcode)
105105
local encoded = frame.encode(message,opcode or frame.TEXT,true)
106-
async_send(encoded, nil, handle_socket_error)
106+
async_send(encoded, nil, handle_socket_err)
107107
end
108108

109109
self.connect = function(_,url,ws_protocol)

src/websocket/frame.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ local decode = function(encoded)
8989
return nil,2
9090
end
9191
local pos,header,payload = sunpack(encoded,'bb')
92+
local high,low
9293
encoded = ssub(encoded,pos)
9394
local bytes = 2
9495
local fin = band(header,bit_7) > 0
@@ -146,7 +147,7 @@ end
146147

147148
local encode_close = function(code,reason)
148149
if code then
149-
data = spack('>H',code)
150+
local data = spack('>H',code)
150151
if reason then
151152
data = data..tostring(reason)
152153
end

src/websocket/server_ev.lua

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ local client = function(sock,protocol)
5858
on_error(err)
5959
end
6060
end
61-
local user_on_message
61+
local user_on_message = function() end
62+
local TEXT = frame.TEXT
63+
local BINARY = frame.BINARY
6264
local on_message = function(message,opcode)
63-
if opcode == frame.TEXT or opcode == frame.BINARY then
64-
if user_on_message then
65-
user_on_message(self,message,opcode)
66-
end
65+
if opcode == TEXT or opcode == BINARY then
66+
user_on_message(self,message,opcode)
6767
elseif opcode == frame.CLOSE then
6868
if self.state ~= 'CLOSING' then
6969
self.state = 'CLOSING'
@@ -75,7 +75,7 @@ local client = function(sock,protocol)
7575
on_close(true,code or 1006,reason)
7676
end,handle_sock_err)
7777
else
78-
on_close(true,code or 1006,reason)
78+
on_close(true,1006,'')
7979
end
8080
end
8181
end
@@ -172,6 +172,7 @@ local listen = function(opts)
172172
client_sock:settimeout(0)
173173
assert(client_sock)
174174
local request = {}
175+
local last
175176
ev.IO.new(
176177
function(loop,read_io)
177178
repeat

src/websocket/sync.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ local connect = function(self,ws_url,ws_protocol)
136136
host = host,
137137
port = port,
138138
protocols = {ws_protocol or ''},
139-
origin = origin,
140139
uri = uri
141140
}
142141
local n,err = self:sock_send(req)

0 commit comments

Comments
 (0)