Sha256: 17199802c19ecf5f13ccd338927e12bf5f6eb43d1bb30fbfd36264bff32123ae
Contents?: true
Size: 679 Bytes
Versions: 5
Compression:
Stored size: 679 Bytes
Contents
#!/usr/bin/env ruby require 'async' require 'async/io/stream' require 'async/http/endpoint' require_relative '../../lib/async/websocket/client' USER = ARGV.pop || "anonymous" URL = ARGV.pop || "http://127.0.0.1:8080" ENDPOINT = Async::HTTP::Endpoint.parse(URL) Async do |task| stdin = Async::IO::Stream.new( Async::IO::Generic.new($stdin) ) Async::WebSocket::Client.connect(ENDPOINT) do |connection| input_task = task.async do while line = stdin.read_until("\n") connection.write({text: line}) connection.flush end end puts "Connected..." while message = connection.read puts "> #{message.inspect}" end ensure input_task&.stop end end
Version data entries
5 entries across 5 versions & 1 rubygems