8000 Update rack example. · socketry/async-websocket@7e99991 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7e99991

Browse files
committed
Update rack example.
1 parent 51583f7 commit 7e99991

File tree

4 files changed

+95
-64
lines changed

4 files changed

+95
-64
lines changed

examples/rack/client.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
endpoint = Async::HTTP::Endpoint.parse(URL)
1515

1616
Async::WebSocket::Client.connect(endpoint) do |connection|
17-
connection.send_text("Hello World")
18-
connection.flush
17+
1000.times do
18+
connection.send_text("Hello World")
19+
connection.flush
1920

20-
while message = connection.read
21-
p message
21+
puts connection.read
2222
end
2323
end
2424
end

examples/rack/gems.locked

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,95 @@
11
PATH
22
remote: ../..
33
specs:
4-
async-websocket (0.22.0)
4+
async-websocket (0.26.1)
55
async-http (~> 0.54)
6-
async-io (~> 1.23)
7-
protocol-rack (~> 0.1.1)
8-
protocol-websocket (~> 0.9.1)
9-
10-
PATH
11-
remote: /Users/samuel/Projects/socketry/protocol-rack
12-
specs:
13-
protocol-rack (0.1.5)
14-
protocol-http (~> 0.23.4)
15-
rack (>= 1.0)
6+
protocol-rack (~> 0.5)
7+
protocol-websocket (~> 0.14)
168

179
GEM
1810
remote: https://rubygems.org/
1911
specs:
20-
async (2.0.3)
21-
console (~> 1.10)
22-
io-event (~> 1.0.0)
23-
timers (~> 4.1)
24-
async-container (0.16.12)
25-
async
26-
async-io
27-
async-http (0.59.1)
28-
async (>= 1.25)
29-
async-io (>= 1.28)
30-
async-pool (>= 0.2)
31-
protocol-http (~> 0.23.1)
32-
protocol-http1 (~> 0.14.0)
33-
protocol-http2 (~> 0.14.0)
34-
traces (>= 0.4.0)
35-
async-http-cache (0.4.2)
12+
async (2.12.0)
13+
console (~> 1.25, >= 1.25.2)
14+
fiber-annotation
15+
io-event (~> 1.6)
16+
async-container (0.18.2)
17+
async (~> 2.10)
18+
async-http (0.67.1)
19+
async (>= 2.10.2)
20+
async-pool (>= 0.6.1)
21+
io-endpoint (~> 0.10, >= 0.10.3)
22+
io-stream (~> 0.4)
23+
protocol-http (~> 0.26.0)
24+
protocol-http1 (~> 0.19.0)
25+
protocol-http2 (~> 0.18.0)
26+
traces (>= 0.10.0)
27+
async-http-cache (0.4.3)
3628
async-http (~> 0.56)
37-
async-io (1.33.0)
38-
async
39-
async-pool (0.3.11)
29+
async-pool (0.6.1)
4030
async (>= 1.25)
41-
build-environment (1.13.0)
42-
console (1.15.3)
43-
fiber-local
44-
falcon (0.42.2)
31+
async-service (0.12.0)
32+
async
33+
async-container (~> 0.16)
34+
console (1.25.2)
35+
fiber-annotation
36+
fiber-local (~> 1.1)
37+
json
38+
falcon (0.47.6)
4539
async
46-
async-container (~> 0.16.0)
47-
async-http (~> 0.57)
40+
async-container (~> 0.18)
41+
async-http (~> 0.66, >= 0.66.3)
4842
async-http-cache (~> 0.4.0)
49-
async-io (~> 1.22)
50-
build-environment (~> 1.13)
43+
async-service (~> 0.10)
5144
bundler
5245
localhost (~> 1.1)
5346
openssl (~> 3.0)
5447
process-metrics (~> 0.2.0)
55-
protocol-rack (~> 0.1.4)
56-
samovar (~> 2.1)
57-
fiber-local (1.0.0)
58-
io-event (1.0.9)
59-
localhost (1.1.9)
48+
protocol-rack (~> 0.5)
49+
samovar (~> 2.3)
50+
fiber-annotation (0.2.0)
51+
fiber-local (1.1.0)
52+
fiber-storage
53+
fiber-storage (0.1.2)
54+
io-endpoint (0.10.3)
55+
io-event (1.6.4)
56+
io-stream (0.4.0)
57+
json (2.7.2)
58+
localhost (1.3.1)
6059
mapping (1.1.1)
61-
nio4r (2.5.8)
62-
openssl (3.0.0)
60+
nio4r (2.7.3)
61+
openssl (3.2.0)
6362
process-metrics (0.2.1)
6463
console (~> 1.8)
6564
samovar (~> 2.1)
66-
protocol-hpack (1.4.2)
67-
protocol-http (0.23.5)
68-
protocol-http1 (0.14.4)
65+
protocol-hpack (1.4.3)
66+
protocol-http (0.26.5)
67+
protocol-http1 (0.19.1)
6968
protocol-http (~> 0.22)
70-
protocol-http2 (0.14.2)
69+
protocol-http2 (0.18.0)
7170
protocol-hpack (~> 1.4)
7271
protocol-http (~> 0.18)
73-
protocol-websocket (0.9.1)
72+
protocol-rack (0.6.0)
73+
protocol-http (~> 0.23)
74+
rack (>= 1.0)
75+
protocol-websocket (0.14.0)
7476
protocol-http (~> 0.2)
75-
protocol-http1 (~> 0.2)
76-
puma (5.6.4)
77+
puma (6.4.2)
7778
nio4r (~> 2.0)
78-
rack (2.2.4)
79-
samovar (2.1.4)
79+
rack (3.1.3)
80+
samovar (2.3.0)
8081
console (~> 1.0)
8182
mapping (~> 1.0)
82-
timers (4.3.3)
83-
traces (0.6.1)
83+
traces (0.11.1)
8484

8585
PLATFORMS
8686
arm64-darwin-21
87+
arm64-darwin-23
8788

8889
DEPENDENCIES
8990
async-websocket!
9091
falcon
91-
protocol-rack!
9292
puma
9393

9494
BUNDLED WITH
95-
2.3.10
95+
2.5.9

examples/rack/gems.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,4 @@
77

88
gem "puma"
99
gem "falcon"
10-
1110
gem "async-websocket", path: "../../"
12-
gem "protocol-rack"

examples/rack/readme.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Rack Example
2+
3+
This example shows how to host a WebSocket server using Rack.
4+
5+
## Usage
6+
7+
Install the dependencies:
8+
9+
~~~ bash
10+
$ bundle update
11+
~~~
12+
13+
Then start the server:
14+
15+
~~~ bash
16+
$ bundle exec falcon serve --bind "http://localhost:9292"
17+
~~~
18+
19+
You can connect to the server using a WebSocket client:
20+
21+
~~~ bash
22+
$ bundle exec ./client.rb "http://localhost:9292"
23+
~~~
24+
25+
### Using Puma
26+
27+
You can also use Puma to host the server:
28+
29+
~~~ bash
30+
$ bundle exec puma --bind "tcp://localhost:9292"
31+
~~~
32+
33+
The command for running the client is the same.

0 commit comments

Comments
 (0)
0