Fixes the room size api which returns string result back to client.
This commit is contained in:
parent
20444adbc9
commit
d12afc5c07
|
@ -105,19 +105,14 @@ function handle_get_room_size(event)
|
||||||
"there are %s occupants in room", tostring(participant_count));
|
"there are %s occupants in room", tostring(participant_count));
|
||||||
else
|
else
|
||||||
log("debug", "no such room exists");
|
log("debug", "no such room exists");
|
||||||
|
return 404;
|
||||||
end
|
end
|
||||||
|
|
||||||
if participant_count > 1 then
|
if participant_count > 1 then
|
||||||
participant_count = participant_count - 1;
|
participant_count = participant_count - 1;
|
||||||
end
|
end
|
||||||
|
|
||||||
local GET_response = {
|
return [[{"participants":]]..participant_count..[[}]];
|
||||||
headers = {
|
|
||||||
content_type = "application/json";
|
|
||||||
};
|
|
||||||
body = [[{"participants":]]..participant_count..[[}]];
|
|
||||||
};
|
|
||||||
return GET_response;
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Handles request for retrieving the room participants details
|
--- Handles request for retrieving the room participants details
|
||||||
|
@ -171,19 +166,14 @@ function handle_get_room (event)
|
||||||
"there are %s occupants in room", tostring(participant_count));
|
"there are %s occupants in room", tostring(participant_count));
|
||||||
else
|
else
|
||||||
log("debug", "no such room exists");
|
log("debug", "no such room exists");
|
||||||
|
return 404;
|
||||||
end
|
end
|
||||||
|
|
||||||
if participant_count > 1 then
|
if participant_count > 1 then
|
||||||
participant_count = participant_count - 1;
|
participant_count = participant_count - 1;
|
||||||
end
|
end
|
||||||
|
|
||||||
local GET_response = {
|
return json.encode(occupants_json);
|
||||||
headers = {
|
|
||||||
content_type = "application/json";
|
|
||||||
};
|
|
||||||
body = json.encode(occupants_json);
|
|
||||||
};
|
|
||||||
return GET_response;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function module.load()
|
function module.load()
|
||||||
|
|
|
@ -66,9 +66,16 @@ function wrap_async_run(event,handler)
|
||||||
-- the handler is done.
|
-- the handler is done.
|
||||||
local response = event.response;
|
local response = event.response;
|
||||||
local async_func = runner(function (event)
|
local async_func = runner(function (event)
|
||||||
response.status_code = handler(event);
|
local result = handler(event);
|
||||||
-- Send the response to the waiting http client.
|
-- if it is a number, it is a status code, else it is the body
|
||||||
response:send();
|
-- result we will return
|
||||||
|
if (tonumber(result) ~= nil) then
|
||||||
|
response.status_code = result;
|
||||||
|
else
|
||||||
|
response.body = result;
|
||||||
|
end;
|
||||||
|
-- Send the response to the waiting http client.
|
||||||
|
response:send();
|
||||||
end)
|
end)
|
||||||
async_func:run(event)
|
async_func:run(event)
|
||||||
-- return true to keep the client http connection open.
|
-- return true to keep the client http connection open.
|
||||||
|
|
Loading…
Reference in New Issue