8000 Update chat example to work with message based protocol. · PeterRunich/async-websocket@7a688a6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7a688a6

Browse files
committed
Update chat example to work with message based protocol.
1 parent feeae30 commit 7a688a6

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

examples/utopia/gems.locked

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ GEM
1212
async-container (0.16.12)
1313
async
1414
async-io
15-
async-http (0.56.6)
15+
async-http (0.59.1)
1616
async (>= 1.25)
1717
async-io (>= 1.28)
1818
async-pool (>= 0.2)
19-
protocol-http (~> 0.22.0)
19+
protocol-http (~> 0.23.1)
2020
protocol-http1 (~> 0.14.0)
2121
protocol-http2 (~> 0.14.0)
22-
traces (~> 0.4.0)
22+
traces (>= 0.4.0)
2323
async-http-cache (0.4.2)
2424
async-http (~> 0.56)
2525
async-io (1.33.0)
2626
async
27-
async-pool (0.3.10)
27+
async-pool (0.3.11)
2828
async (>= 1.25)
2929
async-redis (0.7.0)
3030
async (>= 1.8, < 3.0)
@@ -38,10 +38,11 @@ GEM
3838
rspec (~> 3.0)
3939
rspec-files (~> 1.0)
4040
rspec-memory (~> 1.0)
41-
async-websocket (0.19.0)
41+
async-websocket (0.22.0)
4242
async-http (~> 0.54)
4343
async-io (~> 1.23)
44-
protocol-websocket (~> 0.7.0)
44+
protocol-rack (~> 0.1.1)
45+
protocol-websocket (~> 0.9.1)
4546
bake (0.18.2)
4647
samovar (~> 2.1)
4748
benchmark-http (0.15.1)
@@ -70,17 +71,18 @@ GEM
7071
ffi-module (~> 0.3.0)
7172
diff-lcs (1.5.0)
7273
digest (3.1.0)
73-
falcon (0.40.1)
74+
falcon (0.42.1)
7475
async
7576
async-container (~> 0.16.0)
76-
async-http (~> 0.56.0)
77+
async-http (~> 0.57)
7778
async-http-cache (~> 0.4.0)
7879
async-io (~> 1.22)
7980
build-environment (~> 1.13)
8081
bundler
8182
localhost (~> 1.1)
83+
openssl (~> 3.0)
8284
process-metrics (~> 0.2.0)
83-
rack (>= 1.0)
85+
protocol-rack (~> 0.1.0)
8486
samovar (~> 2.1)
8587
ffi (1.15.5)
8688
ffi-module (0.3.0)
@@ -97,16 +99,17 @@ GEM
9799
shellany (~> 0.0)
98100
thor (>= 0.18.1)
99101
guard-compat (1.2.1)
100-
guard-falcon (0.12.1)
101-
async-container (~> 0.16.0)
102+
guard-falcon (0.13.1)
103+
async-container (~> 0.16)
104+
console (~> 1.0)
102105
falcon (~> 0.35)
103106
guard
104107
guard-compat (~> 1.2)
105108
guard-rspec (4.7.3)
106109
guard (~> 2.1)
107110
guard-compat (~> 1.1)
108111
rspec (>= 2.99.0, < 4.0)
109-
http-accept (2.1.1)
112+
http-accept (2.2.0)
110113
listen (3.7.1)
111114
rb-fsevent (~> 0.10, >= 0.10.3)
112115
rb-inotify (~> 0.9, >= 0.9.10)
@@ -132,20 +135,24 @@ GEM
132135
notiffany (0.1.3)
133136
nenv (~> 0.1)
134137
shellany (~> 0.0)
135-
parser (3.1.2.0)
138+
openssl (3.0.0)
139+
parser (3.1.2.1)
136140
ast (~> 2.4.1)
137141
process-metrics (0.2.1)
138142
console (~> 1.8)
139143
samovar (~> 2.1)
140144
protocol-hpack (1.4.2)
141-
protocol-http (0.22.6)
145+
protocol-http (0.23.5)
142146
protocol-http1 (0.14.4)
143147
protocol-http (~> 0.22)
144148
protocol-http2 (0.14.2)
145149
protocol-hpack (~> 1.4)
146150
protocol-http (~> 0.18)
151+
protocol-rack (0.1.2)
152+
protocol-http (~> 0.23.4)
153+
rack (>= 1.0)
147154
protocol-redis (0.6.1)
148-
protocol-websocket (0.7.5)
155+
protocol-websocket (0.9.1)
149156
protocol-http (~> 0.2)
150157
protocol-http1 (~> 0.2)
151158
pry (0.14.1)
@@ -184,19 +191,19 @@ GEM
184191
thread-local (1.1.0)
185192
timeout (0.3.0)
186193
timers (4.3.3)
187-
traces (0.4.1)
194+
traces (0.6.1)
188195
trenni (3.13.2)
189196
trenni-sanitize (0.6.1)
190197
trenni (~> 3.5)
191-
utopia (2.20.0)
198+
utopia (2.20.1)
192199
concurrent-ruby (~> 1.0)
193200
console (~> 1.0)
194201
http-accept (~> 2.1)
195202
mail (~> 2.6)
196203
mime-types (~> 3.0)
197204
msgpack
198205
net-smtp
199-
rack (~> 2.2)
206+
rack (>= 2.2)
200207
samovar (~> 2.1)
201208
traces
202209
trenni (~> 3.0)

examples/utopia/pages/server/controller.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@
1515
while true
1616
type, name, message = context.listen
1717

18-
connection.write(JSON.parse(message))
18+
# The message is text, but contains JSON.
19+
connection.send_text(message)
1920
connection.flush
2021
end
2122
end
2223
end
2324

2425
while message = connection.read
25-
client.publish(channel, JSON.dump(message))
26+
client.publish(channel, message.buffer)
2627
end
2728
ensure
2829
subscription_task&.stop

0 commit comments

Comments
 (0)
0