mirror of
https://github.com/defold/extension-websocket.git
synced 2025-06-27 09:47:44 +02:00
Added api docs for websocket.send()
This commit is contained in:
parent
f0cf078019
commit
1202731ec8
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user