Permalink
Browse files

Merge pull request #4 from yanivkalfa/add_timer_to_queue_create_reque…

…st_to_fix_handle_logout_case

added a timer to queue create action
  • Loading branch information...
yanivkalfa committed Mar 6, 2017
2 parents 99888bb + ccdff6b commit dbd3eb5d6d453ebfb279997f3f4e12d555030559
Showing with 46 additions and 4 deletions.
  1. +22 −1 Actions/EventActions.lua
  2. +1 −0 Actions/QueueActions.lua
  3. +3 −1 Configs/Constants.lua
  4. +1 −2 LFG.lua
  5. +13 −0 LFG_Incoming.lua
  6. +6 −0 LFG_Outgoing.lua
@@ -55,14 +55,35 @@ function LFG.Actions.Event.update(request)
LFG.Tabs.select("events.viewQueues");
end

function LFG.Actions.Event.delete(request)
function LFG.Actions.Event.delete()
LFG.Outgoing:send(LFG.Constants.EVENTS.E_DELETE, nil, {});
LFG.QueueScrollFrames.queueList = {};
LFG.QueueScrollFrames.updateLFGQueue();
LFG_Settings.event = nil;
LFG.Tabs.select("events.view");
end

function LFG.Actions.Event.remove(event)

if( type(event) ~= "table") then
return false;
end

if (type(event.QTE) == "table" and event.QTE.timer) then
Timer.clearTimer(event.QTE.timer);
end

local foundIndex = table.findIndex(LFG.EventScrollFrames.eventList, function(index, value)
return event.OR == value.OR;
end)

if ( foundIndex ) then
table.remove(LFG.EventScrollFrames.eventList, foundIndex);
LFG.EventScrollFrames.updateLFGEvent();
end

end

function LFG.Actions.Event.cancelQueue(name, event, hideEvent)

if( type(event) ~= "table") then
@@ -24,6 +24,7 @@ function LFG.Actions.Queue.create()
event.QTE = {
expireAt = time() + LFG.Constants.QUEUE_TIMEOUT,
timer = Timer.setTimeout(LFG.Constants.QUEUE_TIMEOUT, LFG.Actions.Queue.cancel, { name, event, true } ),
requestTimer = Timer.setTimeout(LFG.Constants.QUEUE_REQUEST_TIMEOUT, LFG.Actions.Event.remove, { event } ),
queue = queue;
};
LFG.Actions.Queue.count = LFG.Actions.Queue.count + 1;
@@ -3,7 +3,8 @@ LFG.Constants.MAX_PAGE_SIZE = 10;
LFG.Constants.EVENT_ITEM_HEIGHT = 34;
LFG.Constants.MAX_QUEUE_PAGE_SIZE = 10;
LFG.Constants.QUEUE_ITEM_HEIGHT = 25;
LFG.Constants.QUEUE_TIMEOUT = 100; --300;
LFG.Constants.QUEUE_TIMEOUT = 300;
LFG.Constants.QUEUE_REQUEST_TIMEOUT = 4;
LFG.Constants.MAX_FRIENDS = 50;
LFG.Constants.MSG_PREFIX = '__LFG__';
LFG.Constants.PUBLIC_CHANNEL = 'LFG_PUBLIC';
@@ -18,6 +19,7 @@ LFG.Constants.EVENTS = {
Q_REQUEST = 'Q_REQUEST', -- queue request
Q_RESPONSE = 'Q_RESPONSE', -- queue response
Q_CREATE = 'Q_CREATE', -- queue create
Q_CREATE_RES = 'Q_CREATE_RES', -- queue create
Q_DELETE = "Q_DELETE", -- queue delete
Q_ACCEPT = "Q_ACCEPT", -- event accept
Q_DECLINE = "Q_DECLINE", -- event decline
@@ -102,5 +102,4 @@ LFG:bindEvents();
-- todo: add a block list on events and check before returning events or accepting queus if the person is in block list.
-- todo: add commend line
-- todo: add invite / accept funtionality
-- todo: add member count update functionality.
-- todo: find a way to notify user when a event creator has logged of without delisting the group
-- todo: add member count update functionality.
@@ -26,6 +26,18 @@ function LFG.Incoming.Q_DELETE(payload, sender, language, channelString, target,
end
end

function LFG.Incoming.Q_CREATE_RES(payload, sender, language, channelString, target, flags, arg7, channelNumber, channelName, arg8)

local foundIndex = table.findIndex(LFG.EventScrollFrames.eventList, function(index, value)
return sender == value.OR;
end)

local event = LFG.EventScrollFrames.eventList[foundIndex];
if (event and event.QTE.requestTimer) then
Timer.clearTimer(event.QTE.requestTimer);
end
end

function LFG.Incoming.Q_CREATE(payload, sender, language, channelString, target, flags, arg7, channelNumber, channelName, arg8)

if ( LFG_Settings.event.ML and LFG_Settings.event.ML >= 1 and LFG_Settings.event.ML > payload.LVL) then
@@ -58,6 +70,7 @@ function LFG.Incoming.Q_CREATE(payload, sender, language, channelString, target,
end);
local pos = table.getn(LFG.QueueScrollFrames.queueList) + 1;
table.insert(LFG.QueueScrollFrames.queueList, pos, payload);
LFG.Outgoing:send(LFG.Constants.EVENTS.Q_CREATE_RES, sender, {});
LFG.Utils.Table.sort(LFG.QueueScrollFrames.queueList, {OB = "TS"});
LFG.QueueScrollFrames.updateLFGQueue();
end
@@ -18,6 +18,12 @@ function LFG.Outgoing.Q_DELETE(eventType, to, payLoad, options)
SendChatMessage(msg, "WHISPER", "Common", to);
end

function LFG.Outgoing.Q_CREATE_RES(eventType, to, payLoad, options)
local tbl = LFG.Utils.Message.createResponseTbl(eventType, to, payLoad, options);
local msg = LFG.Utils.Message:createResponseMsg(tbl);
SendChatMessage(msg, "WHISPER", "Common", to);
end

function LFG.Outgoing.Q_CREATE(eventType, to, payLoad, options)
local tbl = LFG.Utils.Message.createResponseTbl(eventType, to, payLoad, options);
local msg = LFG.Utils.Message:createResponseMsg(tbl);

0 comments on commit dbd3eb5

Please sign in to comment.