Skip to content

Commit

Permalink
Small refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantin Burkalev authored and Konstantin Burkalev committed May 22, 2018
1 parent 0b89288 commit be54be4
Showing 1 changed file with 2 additions and 23 deletions.
25 changes: 2 additions & 23 deletions src/wiola/wiola.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
--local getdump = require("debug.vardump").getdump

local _M = {
_VERSION = '0.9.0',
_VERSION = '0.9.1',
}

_M.__index = _M
Expand All @@ -18,27 +18,6 @@ setmetatable(_M, {
end
})

---
--- Return index of obj in array t
---
--- @param t table array table
--- @param obj any object to search
--- @return index of obj or -1 if not found
---------------------------------------------------
local arrayIndexOf = function(t, obj)
if type(t) == 'table' then
for i = 1, #t do
if t[i] == obj then
return i
end
end

return -1
else
error("table.indexOf expects table for first argument, " .. type(t) .. " given")
end
end

local wamp_features = {
agent = "wiola/Lua v" .. _M._VERSION,
roles = {
Expand Down Expand Up @@ -619,7 +598,7 @@ function _M:receiveData(regId, data)
else
local realm = dataObj[2]

if arrayIndexOf(config.realms, realm) < 0 and config.realms[1] ~= "*" then
if not has(config.realms, realm) and config.realms[1] ~= "*" then
-- WAMP SPEC: [ABORT, Details|dict, Reason|uri]
self:_putData(session, {
WAMP_MSG_SPEC.ABORT,
Expand Down

0 comments on commit be54be4

Please sign in to comment.