Skip to content

Commit 7edb2f4

Browse files
Konstantin BurkalevKonstantin Burkalev
authored andcommitted
Build minified 0.4.0 version
1 parent 5192fcd commit 7edb2f4

File tree

3 files changed

+30
-28
lines changed

3 files changed

+30
-28
lines changed

build/handler.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ if not redisOk then
2222
end
2323

2424
local sessionId, dataType = wampServer:addConnection(ngx.var.connection, ngx.header["Sec-WebSocket-Protocol"])
25+
" Session Id: ", sessionId, " selected protocol: ", ngx.header["Sec-WebSocket-Protocol"])
2526

2627
local cleanExit = false
2728

build/wiola.lua

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ function _M:_putData(session, data)
213213
local mp = require 'MessagePack'
214214
dataObj = mp.pack(data)
215215
else --if session.wamp_protocol == 'wamp.2.json'
216-
local json = require "resty.libcjson"
216+
local json = require "rapidjson"
217217
dataObj = json.encode(data)
218218
end
219219

@@ -250,7 +250,7 @@ end
250250
function _M:receiveData(regId, data)
251251
local session = self.redis:array_to_hash(self.redis:hgetall("wiSes" .. regId))
252252
session.isWampEstablished = tonumber(session.isWampEstablished)
253-
local json = require "resty.libcjson"
253+
local json = require "rapidjson"
254254
local dataObj
255255

256256
if session.wamp_protocol == 'wamp.2.msgpack' then
@@ -265,7 +265,7 @@ function _M:receiveData(regId, data)
265265
if session.isWampEstablished == 1 then
266266
-- Protocol error: received second hello message - aborting
267267
-- WAMP SPEC: [GOODBYE, Details|dict, Reason|uri]
268-
self:_putData(session, { WAMP_MSG_SPEC.GOODBYE, setmetatable({}, json.object), "wamp.error.system_shutdown" })
268+
self:_putData(session, { WAMP_MSG_SPEC.GOODBYE, setmetatable({}, { __jsontype = 'object' }), "wamp.error.system_shutdown" })
269269
else
270270
local realm = dataObj[2]
271271
if self:_validateURI(realm) then
@@ -284,16 +284,16 @@ function _M:receiveData(regId, data)
284284
self:_putData(session, { WAMP_MSG_SPEC.WELCOME, regId, wamp_features })
285285
else
286286
-- WAMP SPEC: [ABORT, Details|dict, Reason|uri]
287-
self:_putData(session, { WAMP_MSG_SPEC.ABORT, setmetatable({}, json.object), "wamp.error.invalid_uri" })
287+
self:_putData(session, { WAMP_MSG_SPEC.ABORT, setmetatable({}, { __jsontype = 'object' }), "wamp.error.invalid_uri" })
288288
end
289289
end
290290
elseif dataObj[1] == WAMP_MSG_SPEC.ABORT then -- WAMP SPEC: [ABORT, Details|dict, Reason|uri]
291291
-- No response is expected
292292
elseif dataObj[1] == WAMP_MSG_SPEC.GOODBYE then -- WAMP SPEC: [GOODBYE, Details|dict, Reason|uri]
293293
if session.isWampEstablished == 1 then
294-
self:_putData(session, { WAMP_MSG_SPEC.GOODBYE, setmetatable({}, json.object), "wamp.error.goodbye_and_out" })
294+
self:_putData(session, { WAMP_MSG_SPEC.GOODBYE, setmetatable({}, { __jsontype = 'object' }), "wamp.error.goodbye_and_out" })
295295
else
296-
self:_putData(session, { WAMP_MSG_SPEC.GOODBYE, setmetatable({}, json.object), "wamp.error.system_shutdown" })
296+
self:_putData(session, { WAMP_MSG_SPEC.GOODBYE, setmetatable({}, { __jsontype = 'object' }), "wamp.error.system_shutdown" })
297297
end
298298
elseif dataObj[1] == WAMP_MSG_SPEC.ERROR then
299299
-- WAMP SPEC: [ERROR, REQUEST.Type|int, REQUEST.Request|id, Details|dict, Error|uri]
@@ -311,13 +311,13 @@ function _M:receiveData(regId, data)
311311

312312
if #dataObj == 6 then
313313
-- WAMP SPEC: [ERROR, CALL, CALL.Request|id, Details|dict, Error|uri, Arguments|list]
314-
self:_putData(callerSess, { WAMP_MSG_SPEC.ERROR, WAMP_MSG_SPEC.CALL, invoc.CallReqId, setmetatable({}, json.object), dataObj[5], dataObj[6] })
314+
self:_putData(callerSess, { WAMP_MSG_SPEC.ERROR, WAMP_MSG_SPEC.CALL, invoc.CallReqId, setmetatable({}, { __jsontype = 'object' }), dataObj[5], dataObj[6] })
315315
elseif #dataObj == 7 then
316316
-- WAMP SPEC: [ERROR, CALL, CALL.Request|id, Details|dict, Error|uri, Arguments|list, ArgumentsKw|dict]
317-
self:_putData(callerSess, { WAMP_MSG_SPEC.ERROR, WAMP_MSG_SPEC.CALL, invoc.CallReqId, setmetatable({}, json.object), dataObj[5], dataObj[6], dataObj[7] })
317+
self:_putData(callerSess, { WAMP_MSG_SPEC.ERROR, WAMP_MSG_SPEC.CALL, invoc.CallReqId, setmetatable({}, { __jsontype = 'object' }), dataObj[5], dataObj[6], dataObj[7] })
318318
else
319319
-- WAMP SPEC: [ERROR, CALL, CALL.Request|id, Details|dict, Error|uri]
320-
self:_putData(callerSess, { WAMP_MSG_SPEC.ERROR, WAMP_MSG_SPEC.CALL, invoc.CallReqId, setmetatable({}, json.object), dataObj[5] })
320+
self:_putData(callerSess, { WAMP_MSG_SPEC.ERROR, WAMP_MSG_SPEC.CALL, invoc.CallReqId, setmetatable({}, { __jsontype = 'object' }), dataObj[5] })
321321
end
322322

323323
self.redis:del("wiInvoc" .. dataObj[3])
@@ -383,10 +383,10 @@ function _M:receiveData(regId, data)
383383
end
384384
end
385385
else
386-
self:_putData(session, { WAMP_MSG_SPEC.ERROR, WAMP_MSG_SPEC.PUBLISH, dataObj[2], setmetatable({}, json.object), "wamp.error.invalid_uri" })
386+
self:_putData(session, { WAMP_MSG_SPEC.ERROR, WAMP_MSG_SPEC.PUBLISH, dataObj[2], setmetatable({}, { __jsontype = 'object' }), "wamp.error.invalid_uri" })
387387
end
388388
else
389-
self:_putData(session, { WAMP_MSG_SPEC.GOODBYE, setmetatable({}, json.object), "wamp.error.system_shutdown" })
389+
self:_putData(session, { WAMP_MSG_SPEC.GOODBYE, setmetatable({}, { __jsontype = 'object' }), "wamp.error.system_shutdown" })
390390
end
391391
elseif dataObj[1] == WAMP_MSG_SPEC.SUBSCRIBE then -- WAMP SPEC: [SUBSCRIBE, Request|id, Options|dict, Topic|uri]
392392
if session.isWampEstablished == 1 then
@@ -403,10 +403,10 @@ function _M:receiveData(regId, data)
403403
-- WAMP SPEC: [SUBSCRIBED, SUBSCRIBE.Request|id, Subscription|id]
404404
self:_putData(session, { WAMP_MSG_SPEC.SUBSCRIBED, dataObj[2], subscriptionId })
405405
else
406-
self:_putData(session, { WAMP_MSG_SPEC.ERROR, WAMP_MSG_SPEC.SUBSCRIBE, dataObj[2], setmetatable({}, json.object), "wamp.error.invalid_uri" })
406+
self:_putData(session, { WAMP_MSG_SPEC.ERROR, WAMP_MSG_SPEC.SUBSCRIBE, dataObj[2], setmetatable({}, { __jsontype = 'object' }), "wamp.error.invalid_uri" })
407407
end
408408
else
409-
self:_putData(session, { WAMP_MSG_SPEC.GOODBYE, setmetatable({}, json.object), "wamp.error.system_shutdown" })
409+
self:_putData(session, { WAMP_MSG_SPEC.GOODBYE, setmetatable({}, { __jsontype = 'object' }), "wamp.error.system_shutdown" })
410410
end
411411
elseif dataObj[1] == WAMP_MSG_SPEC.UNSUBSCRIBE then -- WAMP SPEC: [UNSUBSCRIBE, Request|id, SUBSCRIBED.Subscription|id]
412412
if session.isWampEstablished == 1 then
@@ -423,10 +423,10 @@ function _M:receiveData(regId, data)
423423
-- WAMP SPEC: [UNSUBSCRIBED, UNSUBSCRIBE.Request|id]
424424
self:_putData(session, { WAMP_MSG_SPEC.UNSUBSCRIBED, dataObj[2] })
425425
else
426-
self:_putData(session, { WAMP_MSG_SPEC.ERROR, WAMP_MSG_SPEC.UNSUBSCRIBE, dataObj[2], setmetatable({}, json.object), "wamp.error.no_such_subscription" })
426+
self:_putData(session, { WAMP_MSG_SPEC.ERROR, WAMP_MSG_SPEC.UNSUBSCRIBE, dataObj[2], setmetatable({}, { __jsontype = 'object' }), "wamp.error.no_such_subscription" })
427427
end
428428
else
429-
self:_putData(session, { WAMP_MSG_SPEC.GOODBYE, setmetatable({}, json.object), "wamp.error.system_shutdown" })
429+
self:_putData(session, { WAMP_MSG_SPEC.GOODBYE, setmetatable({}, { __jsontype = 'object' }), "wamp.error.system_shutdown" })
430430
end
431431
elseif dataObj[1] == WAMP_MSG_SPEC.CALL then
432432
-- WAMP SPEC: [CALL, Request|id, Options|dict, Procedure|uri]
@@ -435,7 +435,7 @@ function _M:receiveData(regId, data)
435435
if session.isWampEstablished == 1 then
436436
if self:_validateURI(dataObj[4]) then
437437
if self.redis:sismember("wiRealm" .. session.realm .. "RPCs", dataObj[4]) == 0 then
438-
self:_putData(session, { WAMP_MSG_SPEC.ERROR, WAMP_MSG_SPEC.REGISTER, dataObj[2], setmetatable({}, json.object), "wamp.error.no_such_procedure" })
438+
self:_putData(session, { WAMP_MSG_SPEC.ERROR, WAMP_MSG_SPEC.REGISTER, dataObj[2], setmetatable({}, { __jsontype = 'object' }), "wamp.error.no_such_procedure" })
439439
else
440440
local callee = tonumber(self.redis:get("wiRPC" .. dataObj[4]))
441441
local tmpK = "wiSes" .. regId .. "TmpSet"
@@ -471,7 +471,7 @@ function _M:receiveData(regId, data)
471471

472472
if allOk == true then
473473

474-
local details = setmetatable({}, json.object)
474+
local details = setmetatable({}, { __jsontype = 'object' })
475475

476476
if dataObj[3].disclose_me ~= nil and dataObj[3].disclose_me == true then
477477
details.caller = regId
@@ -503,16 +503,16 @@ function _M:receiveData(regId, data)
503503
end
504504
end
505505
else
506-
self:_putData(session, { WAMP_MSG_SPEC.ERROR, WAMP_MSG_SPEC.CALL, dataObj[2], setmetatable({}, json.object), "wamp.error.invalid_uri" })
506+
self:_putData(session, { WAMP_MSG_SPEC.ERROR, WAMP_MSG_SPEC.CALL, dataObj[2], setmetatable({}, { __jsontype = 'object' }), "wamp.error.invalid_uri" })
507507
end
508508
else
509-
self:_putData(session, { WAMP_MSG_SPEC.GOODBYE, setmetatable({}, json.object), "wamp.error.system_shutdown" })
509+
self:_putData(session, { WAMP_MSG_SPEC.GOODBYE, setmetatable({}, { __jsontype = 'object' }), "wamp.error.system_shutdown" })
510510
end
511511
elseif dataObj[1] == WAMP_MSG_SPEC.REGISTER then -- WAMP SPEC: [REGISTER, Request|id, Options|dict, Procedure|uri]
512512
if session.isWampEstablished == 1 then
513513
if self:_validateURI(dataObj[4]) then
514514
if self.redis:sismember("wiRealm" .. session.realm .. "RPCs", dataObj[4]) == 1 then
515-
self:_putData(session, { WAMP_MSG_SPEC.ERROR, WAMP_MSG_SPEC.REGISTER, dataObj[2], setmetatable({}, json.object), "wamp.error.procedure_already_exists" })
515+
self:_putData(session, { WAMP_MSG_SPEC.ERROR, WAMP_MSG_SPEC.REGISTER, dataObj[2], setmetatable({}, { __jsontype = 'object' }), "wamp.error.procedure_already_exists" })
516516
else
517517
local registrationId = self:_getRegId()
518518

@@ -525,10 +525,10 @@ function _M:receiveData(regId, data)
525525
self:_putData(session, { WAMP_MSG_SPEC.REGISTERED, dataObj[2], registrationId })
526526
end
527527
else
528-
self:_putData(session, { WAMP_MSG_SPEC.ERROR, WAMP_MSG_SPEC.REGISTER, dataObj[2], setmetatable({}, json.object), "wamp.error.invalid_uri" })
528+
self:_putData(session, { WAMP_MSG_SPEC.ERROR, WAMP_MSG_SPEC.REGISTER, dataObj[2], setmetatable({}, { __jsontype = 'object' }), "wamp.error.invalid_uri" })
529529
end
530530
else
531-
self:_putData(session, { WAMP_MSG_SPEC.GOODBYE, setmetatable({}, json.object), "wamp.error.system_shutdown" })
531+
self:_putData(session, { WAMP_MSG_SPEC.GOODBYE, setmetatable({}, { __jsontype = 'object' }), "wamp.error.system_shutdown" })
532532
end
533533
elseif dataObj[1] == WAMP_MSG_SPEC.UNREGISTER then -- WAMP SPEC: [UNREGISTER, Request|id, REGISTERED.Registration|id]
534534
if session.isWampEstablished == 1 then
@@ -541,10 +541,10 @@ function _M:receiveData(regId, data)
541541
-- WAMP SPEC: [UNREGISTERED, UNREGISTER.Request|id]
542542
self:_putData(session, { WAMP_MSG_SPEC.UNREGISTERED, dataObj[2] })
543543
else
544-
self:_putData(session, { WAMP_MSG_SPEC.ERROR, WAMP_MSG_SPEC.UNREGISTER, dataObj[2], setmetatable({}, json.object), "wamp.error.no_such_registration" })
544+
self:_putData(session, { WAMP_MSG_SPEC.ERROR, WAMP_MSG_SPEC.UNREGISTER, dataObj[2], setmetatable({}, { __jsontype = 'object' }), "wamp.error.no_such_registration" })
545545
end
546546
else
547-
self:_putData(session, { WAMP_MSG_SPEC.GOODBYE, setmetatable({}, json.object), "wamp.error.system_shutdown" })
547+
self:_putData(session, { WAMP_MSG_SPEC.GOODBYE, setmetatable({}, { __jsontype = 'object' }), "wamp.error.system_shutdown" })
548548
end
549549
elseif dataObj[1] == WAMP_MSG_SPEC.YIELD then
550550
-- WAMP SPEC: [YIELD, INVOCATION.Request|id, Options|dict]
@@ -555,7 +555,7 @@ function _M:receiveData(regId, data)
555555
invoc.CallReqId = tonumber(invoc.CallReqId)
556556
local callerSess = self.redis:array_to_hash(self.redis:hgetall("wiSes" .. invoc.callerSesId))
557557

558-
local details = setmetatable({}, json.object)
558+
local details = setmetatable({}, { __jsontype = 'object' })
559559

560560
if dataObj[3].receive_progress ~= nil and dataObj[3].receive_progress == true then
561561
details.receive_progress = true
@@ -574,7 +574,7 @@ function _M:receiveData(regId, data)
574574
self:_putData(callerSess, { WAMP_MSG_SPEC.RESULT, invoc.CallReqId, details })
575575
end
576576
else
577-
self:_putData(session, { WAMP_MSG_SPEC.GOODBYE, setmetatable({}, json.object), "wamp.error.system_shutdown" })
577+
self:_putData(session, { WAMP_MSG_SPEC.GOODBYE, setmetatable({}, { __jsontype = 'object' }), "wamp.error.system_shutdown" })
578578
end
579579
else
580580

@@ -601,7 +601,7 @@ end
601601
--
602602
function _M:processPostData(sid, realm, data)
603603

604-
local json = require "resty.libcjson"
604+
local json = require "rapidjson"
605605
local dataObj = json.decode(data)
606606
local res
607607
local httpCode

src/wiola/handler.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ if not redisOk then
2626
end
2727

2828
local sessionId, dataType = wampServer:addConnection(ngx.var.connection, ngx.header["Sec-WebSocket-Protocol"])
29-
ngx.log(ngx.DEBUG, "Adding connection to list. Conn Id: ", ngx.var.connection, " Session Id: ", sessionId, " selected protocol: ", ngx.header["Sec-WebSocket-Protocol"])
29+
ngx.log(ngx.DEBUG, "Adding connection to list. Conn Id: ", ngx.var.connection,
30+
" Session Id: ", sessionId, " selected protocol: ", ngx.header["Sec-WebSocket-Protocol"])
3031

3132
local cleanExit = false
3233

0 commit comments

Comments
 (0)