File tree 7 files changed +6
-29
lines changed
fixtures/rack_application 7 files changed +6
-29
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,6 @@ Gem::Specification.new do |spec|
25
25
spec . required_ruby_version = ">= 3.0"
26
26
27
27
spec . add_dependency "async-http" , "~> 0.54"
28
- spec . add_dependency "async-io" , "~> 1.23"
29
- spec . add_dependency "protocol-rack" , "~> 0.1"
28
+ spec . add_dependency "protocol-rack" , "~> 0.5"
30
29
spec . add_dependency "protocol-websocket" , "~> 0.11"
31
30
end
Original file line number Diff line number Diff line change 5
5
# Copyright, 2018-2022, by Samuel Williams.
6
6
7
7
require 'async'
8
- require 'async/io/stream'
9
8
require 'async/http/endpoint'
10
9
require_relative '../../lib/async/websocket/client'
11
10
require 'protocol/websocket/json_message'
15
14
ENDPOINT = Async ::HTTP ::Endpoint . parse ( URL )
16
15
17
16
Async do |task |
18
- stdin = Async ::IO ::Stream . new (
19
- Async ::IO ::Generic . new ( $stdin)
20
- )
21
-
22
17
Async ::WebSocket ::Client . connect ( ENDPOINT ) do |connection |
23
18
input_task = task . async do
24
- while line = stdin . read_until ( " \n " )
19
+ while line = $ stdin. gets
25
20
message = Protocol ::WebSocket ::JSONMessage . generate ( { text : line } )
26
21
message . send ( connection )
27
22
connection . flush
<
8000
tr>Original file line number Diff line number Diff line change 7
7
require 'async'
8
8
require 'async/semaphore'
9
9
require 'async/clock'
10
- require 'async/io/stream'
11
10
require 'async/http/endpoint'
12
11
require 'protocol/websocket/json_message'
13
12
require_relative '../../lib/async/websocket/client'
@@ -28,7 +27,7 @@ class Command < Samovar::Command
28
27
29
28
def local_address
30
29
if bind = @options [ :bind ]
31
- Async :: IO :: Address . tcp ( bind , 0 )
30
+ Addrinfo . tcp ( bind , 0 )
32
31
end
33
32
end
34
33
Original file line number Diff line number Diff line change 6
6
# Copyright, 2020, by Juan Antonio Martín Lucas.
7
7
8
8
require 'async'
9
- require 'async/io/stream'
10
9
require 'async/http/endpoint'
11
10
require 'async/websocket/client'
12
11
13
12
USER = ARGV . pop || "anonymous"
14
13
URL = ARGV . pop || "http://127.0.0.1:7070"
15
14
16
15
Async do |task |
17
- stdin = Async ::IO ::Stream . new (
18
- Async ::IO ::Generic . new ( $stdin)
19
- )
20
-
21
16
endpoint = Async ::HTTP ::Endpoint . parse ( URL )
22
17
23
18
Async ::WebSocket ::Client . connect ( endpoint ) do |connection |
24
19
task . async do
25
20
$stdout. write "> "
26
21
27
- while line = stdin . read_until ( " \n " )
22
+ while line = $ stdin. gets
28
23
connection . write ( { input : line } )
29
24
connection . flush
30
25
Original file line number Diff line number Diff line change 5
5
# Copyright, 2020-2022, by Samuel Williams.
6
6
7
7
require 'async'
8
- require 'async/io/stream'
9
8
require 'async/http/endpoint'
10
9
11
10
require 'hexdump'
Original file line number Diff line number Diff line change 5
5
# Copyright, 2018-2023, by Samuel Williams.
6
6
7
7
require 'async'
8
- require 'async/io/stream'
9
8
require 'async/http/endpoint'
10
9
require 'async/websocket/client'
11
10
12
11
USER = ARGV . pop || "anonymous"
13
12
URL = ARGV . pop || "http://localhost:7070"
14
13
15
14
Async do |task |
16
- stdin = Async ::IO ::Stream . new (
17
- Async ::IO ::Generic . new ( $stdin)
18
- )
19
-
20
15
endpoint = Async ::HTTP ::Endpoint . parse ( URL )
21
16
headers = { 'token' => 'wubalubadubdub' }
22
17
23
18
Async ::WebSocket ::Client . open ( endpoint , headers : headers ) do |connection |
24
19
input_task = task . async do
25
- while line = stdin . read_until ( " \n " )
20
+ while line = $ stdin. gets
26
21
connection . write ( { user : USER , text : line } )
27
22
connection . flush
28
23
end
Original file line number Diff line number Diff line change @@ -20,23 +20,18 @@ $ bundle add async-websocket
20
20
# !/usr/bin/env ruby
21
21
22
22
require ' async'
23
- require ' async/io/stream'
24
23
require ' async/http/endpoint'
25
24
require ' async/websocket/client'
26
25
27
26
USER = ARGV .pop || " anonymous"
28
27
URL = ARGV .pop || " http://localhost:7070"
29
28
30
29
Async do |task |
31
- stdin = Async ::IO ::Stream .new (
32
- Async ::IO ::Generic .new ($stdin )
33
- )
34
-
35
30
endpoint = Async ::HTTP ::Endpoint .parse(URL )
36
31
37
32
Async ::WebSocket ::Client .connect(endpoint) do |connection |
38
33
input_task = task.async do
39
- while line = stdin.read_until( " \n " )
34
+ while line = $ stdin .gets
40
35
connection.write({user: USER , text: line})
41
36
connection.flush
42
37
end
You can’t perform that action at this time.
0 commit comments