async-websocket 0.12.0 → 0.12.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d59d147ba4ce20f2134da282eeb61c2d0804c8e5f28d92dec8d66b58822ba04
4
- data.tar.gz: f12775e9382b040bc22b9b2953254573ebd107cd548fde8d6a81395a3fdd0aba
3
+ metadata.gz: ce69a19f9de2e43719dfb5f5d078a50ac861132e153195f1762fed28114bc6aa
4
+ data.tar.gz: ff8d041d95a76e68c2352db339802957472f4cf77aaa948242cdec8f6a7281d5
5
5
  SHA512:
6
- metadata.gz: 618c0aff69a52d971c7b4e2c59200be9633b7835e26dfbc01971c1496ae73bf11f98f74012b72a63cc35331604d8dee9029cee5466a01bcfd329bdd21705cf45
7
- data.tar.gz: 58567157e1ae431d60cbcf62a1bf88cb757e89bd89a1dd996ee442ad05dbb3595da9f8ae469b2273370e92b9f3115fde05019d0e72f178d49b992637eff4e061
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
- yield handler.call(framer, protocol)
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
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Async
22
22
  module WebSocket
23
- VERSION = "0.12.0"
23
+ VERSION = "0.12.1"
24
24
  end
25
25
  end
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.0
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