mirror of
https://github.com/defold/extension-websocket.git
synced 2025-06-27 09:47:44 +02:00
Merge branch 'master' of github.com:defold/extension-websocket
This commit is contained in:
commit
ab1b52c676
@ -100,6 +100,35 @@
|
|||||||
type: object
|
type: object
|
||||||
desc: the websocket connection
|
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
|
- name: EVENT_CONNECTED
|
||||||
|
Loading…
x
Reference in New Issue
Block a user