From 1202731ec8d1bd0e06c8b19b07c5da7014929ba9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Ritzl?= Date: Fri, 4 Sep 2020 11:22:54 +0200 Subject: [PATCH] Added api docs for websocket.send() --- websocket/api/api.script_api | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/websocket/api/api.script_api b/websocket/api/api.script_api index b2c8b86..855e072 100644 --- a/websocket/api/api.script_api +++ b/websocket/api/api.script_api @@ -100,6 +100,35 @@ type: object desc: the websocket connection +#***************************************************************************************************** + + - name: send + type: function + desc: Send data on a websocket + parameters: + - name: connection + type: object + desc: the websocket connection + - name: message + type: string + desc: the message to send + + examples: + - desc: |- + ```lua + local function websocket_callback(self, conn, data) + if data.event == websocket.EVENT_CONNECTED then + websocket.send(conn, "Hello from the other side") + end + end + + function init(self) + self.url = "ws://echo.websocket.org" + local params = {} + self.connection = websocket.connect(self.url, params, websocket_callback) + end + ``` + #***************************************************************************************************** - name: EVENT_CONNECTED