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