Sha256: c3a2ae09985229cd20967547a9f03bcf7cb17c7c68cac74562de422bfb616427
Contents?: true
Size: 806 Bytes
Versions: 1
Compression:
Stored size: 806 Bytes
Contents
#!/usr/bin/env ruby require 'async/reactor' require 'async/io/stream' require 'async/http/url_endpoint' require 'async/websocket/client' URL = ARGV.pop USER = ARGV.pop Async::Reactor.run do |task| endpoint = Async::HTTP::URLEndpoint.parse(URL) endpoint.connect do |socket| connection = Async::WebSocket::Client.new(socket, URL) connection.send_message({ user: USER, status: "connected", }) task.async do stdin = Async::IO::Stream.new( Async::IO::Generic.new($stdin) ) puts "Waiting for input..." while line = stdin.read_until("\n") puts "Sending text: #{line}" connection.send_message({ user: USER, text: line, }) end end while message = connection.next_message puts "Message from server: #{message.inspect}" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
async-websocket-0.3.0 | chat/client.rb |