kd2bwzgen

[ComputerCraft PR 395] Websocket connection to pseudo-file

Sep 24th, 2017
416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.34 KB | None | 0 0
  1. local function wscToFile(wsc)
  2.     local ret = {}
  3.     ret.readAll = wsc.recieve
  4.     ret.readLine = wsc.recieve
  5.     ret.write = wsc.send
  6.     function ret.writeLine(sData)
  7.         wsc.send(sData.."\n")
  8.     end
  9.     ret.close = wsc.close
  10.     ret.rawconnection = wsc
  11.     return ret
  12. end
  13.  
  14. function connectToWS(...)
  15.     local wsc = http.websocket(...)
  16.     return wscToFile(wsc)
  17. end
Add Comment
Please, Sign In to add comment