Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shell.run('pastebin get 4nRg9CHU json')
- os.loadAPI('json')
- io.write('Who are you? ')
- local username = io.read()
- local socket, e = http.websocket("wss://a295-189-54-244-176.sa.ngrok.io")
- local function receive ()
- local message = socket.receive()
- local data = json.decode(message)
- print('<' .. data.author.username .. '>', data.content)
- end
- local function send ()
- term.clearLine()
- local content = io.read()
- socket.send(json.encode({ content = content, username = username }))
- end
- if socket then
- while true do
- parallel.waitForAny(receive, send)
- end
- end
- error(e)
Advertisement
Add Comment
Please, Sign In to add comment