websocket_message event
Fired when a websocket message is received. websocket.receive acts as a wrapper around this event, allowing you to write code in a a more linear fashion.
|
|||
Open a websocket, send a message and then wait for an incoming message. | |||
Code | <nowiki>
local wsUrl = "wss://echo.websocket.org/"
local ws, err = http.websocket(wsUrl)
if ws then
ws.send("Hello")
while true do
local event, url, contents = os.pullEvent("websocket_message")
if url == wsUrl then
print(contents)
break
end
end
ws.close()
end
</nowiki>
|
websocket_message Event | |
---|---|
Returns
| |
Source | CC:Tweaked |
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.