diff --git a/WebSocket.lua b/WebSocket.lua index 8625981..fcb1603 100644 --- a/WebSocket.lua +++ b/WebSocket.lua @@ -61,16 +61,15 @@ local ws = function (dict) if response.Success then local msg = response.Body - -- Rest of the code + if notExists(messages, msg) then + table.insert(messages, msg) + if notEmpty(msg) then + onMessage(msg) + end + end else error("Error Polling Messages: " .. response.StatusCode .. " " .. response.StatusMessage) end - if notExists(messages, msg) then - table.insert(messages, msg) - if notEmpty(msg) then - onMessage(msg) - end - end end end) coroutine.resume(loop)