websocket.receive

From ComputerCraft
Jump to: navigation, search

websocket.receive
Function
Syntax
websocket.receive()
Returns number
API http
Source CC:Tweaked (source)

Wait until a message has been received from this websocket.

ExampleExampleReceiving a websocket message
Opens a websocket to an echo server, sends a message and waits for the response.
Code
local ws, err = http.websocket("wss://echo.websocket.org")
if ws then
  ws.send("Hello")
  print(ws.receive())
  ws.close()
end
Output
Hello