async-websocket 0.12.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/examples/rack/client.rb +20 -0
- data/examples/rack/config.ru +14 -0
- data/lib/async/websocket/adapters/rack.rb +4 -1
- data/lib/async/websocket/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce69a19f9de2e43719dfb5f5d078a50ac861132e153195f1762fed28114bc6aa
|
4
|
+
data.tar.gz: ff8d041d95a76e68c2352db339802957472f4cf77aaa948242cdec8f6a7281d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4ed4461f1a5ece9ad6866220d6eae27cd1f61cd0572765c7e7412b8bb4a2f2aba0043008b3d70f94025de6a29c00d55ec95de2e4ab890000594038dc9cf7126
|
7
|
+
data.tar.gz: d012e7149f746dbfbae8bade2e76efc0432594ef0eb47b84cd867a89b79dc0bb8ea76380900304428fd7dfc1d38f6a9bb7cd26ff626e5f913faa6a4cbfa6ead0
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'async'
|
4
|
+
require 'async/io/stream'
|
5
|
+
require 'async/http/endpoint'
|
6
|
+
require 'async/websocket/client'
|
7
|
+
|
8
|
+
URL = ARGV.pop || "http://127.0.0.1:7070"
|
9
|
+
|
10
|
+
Async do |task|
|
11
|
+
endpoint = Async::HTTP::Endpoint.parse(URL)
|
12
|
+
|
13
|
+
Async::WebSocket::Client.connect(endpoint) do |connection|
|
14
|
+
connection.write ["Hello World"]
|
15
|
+
|
16
|
+
while message = connection.read
|
17
|
+
p message
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env -S falcon serve --bind http://127.0.0.1:7070 --count 1 -c
|
2
|
+
|
3
|
+
require 'async/websocket/adapters/rack'
|
4
|
+
|
5
|
+
app = lambda do |env|
|
6
|
+
Async::WebSocket::Adapters::Rack.open(env, protocols: ['ws']) do |connection|
|
7
|
+
p [env["REMOTE_ADDR"], "connected", env["VERSION"]]
|
8
|
+
message = connection.read
|
9
|
+
p message
|
10
|
+
connection.write message
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
run app
|
@@ -43,7 +43,10 @@ module Async
|
|
43
43
|
response = Response.for(request, headers, protocol: protocol, **options) do |stream|
|
44
44
|
framer = Protocol::WebSocket::Framer.new(stream)
|
45
45
|
|
46
|
-
|
46
|
+
connection = handler.call(framer, protocol)
|
47
|
+
yield connection
|
48
|
+
|
49
|
+
connection.close unless connection.closed?
|
47
50
|
end
|
48
51
|
|
49
52
|
headers = response.headers
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-websocket
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.
|
4
|
+
version: 0.12.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -156,6 +156,8 @@ files:
|
|
156
156
|
- examples/chat/multi-client.rb
|
157
157
|
- examples/mud/client.rb
|
158
158
|
- examples/mud/config.ru
|
159
|
+
- examples/rack/client.rb
|
160
|
+
- examples/rack/config.ru
|
159
161
|
- examples/utopia/.bowerrc
|
160
162
|
- examples/utopia/.gitignore
|
161
163
|
- examples/utopia/.rspec
|