Added status code to callback when the server closes the connection (#45)

* Added WebSocket close code to callback

Also added message and code for HTML5

* Unify disconnect handling for wslay and html5
This commit is contained in:
Björn Ritzl
2022-06-23 20:52:46 +02:00
committed by GitHub
parent 5c5736d8bc
commit 24bb291c72
7 changed files with 40 additions and 25 deletions

View File

@@ -1,4 +1,4 @@
local URL = "echo.websocket.org"
local URL = "echo.websocket.events"
local function click_button(node, action)
return gui.is_enabled(node) and action.pressed and gui.pick_node(node, action.x, action.y)
@@ -57,7 +57,7 @@ end
local function websocket_callback(self, conn, data)
if data.event == websocket.EVENT_DISCONNECTED then
log("Disconnected: " .. tostring(conn))
log("Disconnected: " .. tostring(conn) .. " Code: " .. data.code .. " Message: " .. tostring(data.message))
self.connection = nil
update_gui(self)
elseif data.event == websocket.EVENT_CONNECTED then