From 176f2130607310a51a8f082b90c31874457b2d43 Mon Sep 17 00:00:00 2001 From: JCash Date: Tue, 13 Oct 2020 09:14:21 +0200 Subject: [PATCH] updated documentation --- docs/index.md | 14 ++++++-------- websocket/api/api.script_api | 11 ++++++----- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/docs/index.md b/docs/index.md index c26656e..57f5517 100644 --- a/docs/index.md +++ b/docs/index.md @@ -14,18 +14,16 @@ Here is how you connect to a websocket and listen to events: ```lua local function websocket_callback(self, conn, data) if data.event == websocket.EVENT_DISCONNECTED then - print("disconnected " .. conn) + log("Disconnected: " .. tostring(conn)) self.connection = nil + update_gui(self) elseif data.event == websocket.EVENT_CONNECTED then - print("Connected " .. conn) - -- self.connection = conn + update_gui(self) + log("Connected: " .. tostring(conn)) elseif data.event == websocket.EVENT_ERROR then - print("Error:", data.message) + log("Error: '" .. data.error .. "'") elseif data.event == websocket.EVENT_MESSAGE then - print("Receiving: '" .. tostring(data.message) .. "'") - end - elseif data.event == websocket.EVENT_DISCONNECTED then - print("Disconnected: '" .. tostring(data.message) .. "'") + log("Receiving: '" .. tostring(data.message) .. "'") end end diff --git a/websocket/api/api.script_api b/websocket/api/api.script_api index 855e072..39f2f3a 100644 --- a/websocket/api/api.script_api +++ b/websocket/api/api.script_api @@ -65,15 +65,16 @@ ```lua local function websocket_callback(self, conn, data) if data.event == websocket.EVENT_DISCONNECTED then - print("disconnected " .. conn) + log("Disconnected: " .. tostring(conn)) self.connection = nil + update_gui(self) elseif data.event == websocket.EVENT_CONNECTED then - print("Connected " .. conn) - -- self.connection = conn + update_gui(self) + log("Connected: " .. tostring(conn)) elseif data.event == websocket.EVENT_ERROR then - print("Error:", data.error) + log("Error: '" .. data.error .. "'") elseif data.event == websocket.EVENT_MESSAGE then - print("Receiving: '" .. tostring(data.message) .. "'") + log("Receiving: '" .. tostring(data.message) .. "'") end end