async-websocket 0.14.0 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/lib/async/websocket/adapters/rack.rb +1 -1
  3. data/lib/async/websocket/client.rb +7 -1
  4. data/lib/async/websocket/version.rb +1 -1
  5. metadata +60 -84
  6. data/.editorconfig +0 -6
  7. data/.gitignore +0 -13
  8. data/.rspec +0 -3
  9. data/.travis.yml +0 -21
  10. data/Gemfile +0 -7
  11. data/README.md +0 -143
  12. data/async-websocket.gemspec +0 -29
  13. data/examples/chat/.env +0 -3
  14. data/examples/chat/README.md +0 -147
  15. data/examples/chat/client.rb +0 -32
  16. data/examples/chat/config.ru +0 -150
  17. data/examples/chat/multi-client.rb +0 -79
  18. data/examples/mud/client.rb +0 -34
  19. data/examples/mud/config.ru +0 -142
  20. data/examples/rack/client.rb +0 -19
  21. data/examples/rack/config.ru +0 -12
  22. data/examples/utopia/.bowerrc +0 -4
  23. data/examples/utopia/.gitignore +0 -9
  24. data/examples/utopia/.rspec +0 -4
  25. data/examples/utopia/Gemfile +0 -33
  26. data/examples/utopia/Guardfile +0 -29
  27. data/examples/utopia/README.md +0 -16
  28. data/examples/utopia/Rakefile +0 -8
  29. data/examples/utopia/config.ru +0 -47
  30. data/examples/utopia/config/README.md +0 -7
  31. data/examples/utopia/config/environment.rb +0 -8
  32. data/examples/utopia/lib/readme.txt +0 -1
  33. data/examples/utopia/pages/_heading.xnode +0 -2
  34. data/examples/utopia/pages/_page.xnode +0 -30
  35. data/examples/utopia/pages/client/client.js +0 -28
  36. data/examples/utopia/pages/client/index.xnode +0 -8
  37. data/examples/utopia/pages/errors/exception.xnode +0 -5
  38. data/examples/utopia/pages/errors/file-not-found.xnode +0 -5
  39. data/examples/utopia/pages/links.yaml +0 -2
  40. data/examples/utopia/pages/server/controller.rb +0 -26
  41. data/examples/utopia/public/_static/icon.png +0 -0
  42. data/examples/utopia/public/_static/site.css +0 -205
  43. data/examples/utopia/public/_static/utopia-background.svg +0 -1
  44. data/examples/utopia/public/_static/utopia.svg +0 -1
  45. data/examples/utopia/public/readme.txt +0 -1
  46. data/examples/utopia/spec/spec_helper.rb +0 -31
  47. data/examples/utopia/spec/website_context.rb +0 -11
  48. data/examples/utopia/spec/website_spec.rb +0 -56
  49. data/examples/utopia/tasks/bower.rake +0 -45
  50. data/examples/utopia/tasks/deploy.rake +0 -13
  51. data/examples/utopia/tasks/development.rake +0 -34
  52. data/examples/utopia/tasks/environment.rake +0 -17
  53. data/examples/utopia/tasks/log.rake +0 -17
  54. data/examples/utopia/tasks/static.rake +0 -43
  55. data/spec/async/websocket/adapters/rack/client.rb +0 -38
  56. data/spec/async/websocket/adapters/rack/config.ru +0 -23
  57. data/spec/async/websocket/adapters/rack_spec.rb +0 -84
  58. data/spec/async/websocket/connection_spec.rb +0 -34
  59. data/spec/async/websocket/server_examples.rb +0 -117
  60. data/spec/async/websocket/server_spec.rb +0 -31
  61. data/spec/async/websocket/upgrade.rb +0 -43
  62. data/spec/spec_helper.rb +0 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cc7cbd8769e7a5f2c98114c19e3e5b17b8e65b1d172e961b2efaca084b108dda
4
- data.tar.gz: 25f69580b9e2f8839c2e3408bb926430eb720e9ec98ff483b4e69d9c3202f207
3
+ metadata.gz: f8972fd15aa98fb4bd1ebf46347e36c64346e3f0d4c45e52971706a5a5ca1557
4
+ data.tar.gz: 6006fd81c88658fd97ef58415ec1f13437158edec1a7d3c709bece3c0deb972b
5
5
  SHA512:
6
- metadata.gz: dee41300f15a14eab436499d4ffaf3ec6906bd23000b4f2d1d5db996d70d43aec64f63d4c444731888eed71ecb6258a3361db643b782c815b85e74a062e45e7e
7
- data.tar.gz: 68228e3e5abb6ac3eab178ecaf4d7a2e4556d6baa99c088b4b0bab6788cef669d1fdd1dae54a512b042b586fe35f94b2031d0540aa7261d3c2af26cffc5eaad5
6
+ metadata.gz: 3cdc9384c146123fa9f73655de2ebaeba9eee1a19d8137d1b2db756ddc2514b9ab150ce16642d9fffeb15b896ba7da4446d02db8fe0b1bade071990efb42897d
7
+ data.tar.gz: 0e6ba0417a711ca7ac680ff4b613c60b2b6b6769c231f11d8ce7cfd913ae805e662741d3231895b66242bc7feb32e722d7e562d869a8cc4f83099ff9b736b08c
@@ -63,7 +63,7 @@ module Async
63
63
  ])
64
64
  end
65
65
 
66
- return [response.status, headers, response.body]
66
+ return [response.status, headers.to_h, response.body]
67
67
  end
68
68
  end
69
69
  end
@@ -100,9 +100,15 @@ module Async
100
100
  end
101
101
 
102
102
  protocol = response.headers[SEC_WEBSOCKET_PROTOCOL]&.first
103
- framer = Framer.new(pool, connection, response.stream)
103
+ stream = response.stream
104
+ response = nil
105
+
106
+ framer = Framer.new(pool, connection, stream)
107
+ connection = nil
104
108
 
105
109
  handler.call(framer, protocol, **@options, &block)
110
+ ensure
111
+ pool.release(connection) if connection
106
112
  end
107
113
  end
108
114
  end
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Async
22
22
  module WebSocket
23
- VERSION = "0.14.0"
23
+ VERSION = "0.15.0"
24
24
  end
25
25
  end
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-websocket
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-08 00:00:00.000000000 Z
11
+ date: 2020-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: async-io
14
+ name: async-http
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.23'
19
+ version: '0.51'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.23'
26
+ version: '0.51'
27
27
  - !ruby/object:Gem::Dependency
28
- name: async-http
28
+ name: async-io
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.51'
33
+ version: '1.23'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.51'
40
+ version: '1.23'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: protocol-websocket
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -67,21 +67,21 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: falcon
70
+ name: bake-bundler
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '0.34'
75
+ version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: '0.34'
82
+ version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: covered
84
+ name: bake-modernize
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -108,6 +108,48 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: covered
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: falcon
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '0.34'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '0.34'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rack-test
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
111
153
  - !ruby/object:Gem::Dependency
112
154
  name: rspec
113
155
  requirement: !ruby/object:Gem::Requirement
@@ -123,7 +165,7 @@ dependencies:
123
165
  - !ruby/object:Gem::Version
124
166
  version: '3.6'
125
167
  - !ruby/object:Gem::Dependency
126
- name: bake-bundler
168
+ name: utopia-project
127
169
  requirement: !ruby/object:Gem::Requirement
128
170
  requirements:
129
171
  - - ">="
@@ -137,61 +179,11 @@ dependencies:
137
179
  - !ruby/object:Gem::Version
138
180
  version: '0'
139
181
  description:
140
- email:
141
- - samuel.williams@oriontransfer.co.nz
182
+ email:
142
183
  executables: []
143
184
  extensions: []
144
185
  extra_rdoc_files: []
145
186
  files:
146
- - ".editorconfig"
147
- - ".gitignore"
148
- - ".rspec"
149
- - ".travis.yml"
150
- - Gemfile
151
- - README.md
152
- - async-websocket.gemspec
153
- - examples/chat/.env
154
- - examples/chat/README.md
155
- - examples/chat/client.rb
156
- - examples/chat/config.ru
157
- - examples/chat/multi-client.rb
158
- - examples/mud/client.rb
159
- - examples/mud/config.ru
160
- - examples/rack/client.rb
161
- - examples/rack/config.ru
162
- - examples/utopia/.bowerrc
163
- - examples/utopia/.gitignore
164
- - examples/utopia/.rspec
165
- - examples/utopia/Gemfile
166
- - examples/utopia/Guardfile
167
- - examples/utopia/README.md
168
- - examples/utopia/Rakefile
169
- - examples/utopia/config.ru
170
- - examples/utopia/config/README.md
171
- - examples/utopia/config/environment.rb
172
- - examples/utopia/lib/readme.txt
173
- - examples/utopia/pages/_heading.xnode
174
- - examples/utopia/pages/_page.xnode
175
- - examples/utopia/pages/client/client.js
176
- - examples/utopia/pages/client/index.xnode
177
- - examples/utopia/pages/errors/exception.xnode
178
- - examples/utopia/pages/errors/file-not-found.xnode
179
- - examples/utopia/pages/links.yaml
180
- - examples/utopia/pages/server/controller.rb
181
- - examples/utopia/public/_static/icon.png
182
- - examples/utopia/public/_static/site.css
183
- - examples/utopia/public/_static/utopia-background.svg
184
- - examples/utopia/public/_static/utopia.svg
185
- - examples/utopia/public/readme.txt
186
- - examples/utopia/spec/spec_helper.rb
187
- - examples/utopia/spec/website_context.rb
188
- - examples/utopia/spec/website_spec.rb
189
- - examples/utopia/tasks/bower.rake
190
- - examples/utopia/tasks/deploy.rake
191
- - examples/utopia/tasks/development.rake
192
- - examples/utopia/tasks/environment.rake
193
- - examples/utopia/tasks/log.rake
194
- - examples/utopia/tasks/static.rake
195
187
  - lib/async/websocket.rb
196
188
  - lib/async/websocket/adapters/rack.rb
197
189
  - lib/async/websocket/client.rb
@@ -206,15 +198,7 @@ files:
206
198
  - lib/async/websocket/upgrade_request.rb
207
199
  - lib/async/websocket/upgrade_response.rb
208
200
  - lib/async/websocket/version.rb
209
- - spec/async/websocket/adapters/rack/client.rb
210
- - spec/async/websocket/adapters/rack/config.ru
211
- - spec/async/websocket/adapters/rack_spec.rb
212
- - spec/async/websocket/connection_spec.rb
213
- - spec/async/websocket/server_examples.rb
214
- - spec/async/websocket/server_spec.rb
215
- - spec/async/websocket/upgrade.rb
216
- - spec/spec_helper.rb
217
- homepage: ''
201
+ homepage: https://github.com/socketry/async-websocket
218
202
  licenses:
219
203
  - MIT
220
204
  metadata: {}
@@ -237,12 +221,4 @@ rubygems_version: 3.1.2
237
221
  signing_key:
238
222
  specification_version: 4
239
223
  summary: An async websocket library on top of websocket-driver.
240
- test_files:
241
- - spec/async/websocket/adapters/rack/client.rb
242
- - spec/async/websocket/adapters/rack/config.ru
243
- - spec/async/websocket/adapters/rack_spec.rb
244
- - spec/async/websocket/connection_spec.rb
245
- - spec/async/websocket/server_examples.rb
246
- - spec/async/websocket/server_spec.rb
247
- - spec/async/websocket/upgrade.rb
248
- - spec/spec_helper.rb
224
+ test_files: []
@@ -1,6 +0,0 @@
1
- root = true
2
-
3
- [*]
4
- indent_style = tab
5
- indent_size = 2
6
-
data/.gitignore DELETED
@@ -1,13 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
12
- Gemfile.lock
13
- .covered.db
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --warnings
3
- --require spec_helper
@@ -1,21 +0,0 @@
1
- language: ruby
2
- dist: xenial
3
- cache: bundler
4
-
5
- script: bundle exec rspec
6
-
7
- matrix:
8
- include:
9
- - rvm: 2.5
10
- - rvm: 2.6
11
- - rvm: 2.7
12
- - rvm: 2.6
13
- env: COVERAGE=PartialSummary,Coveralls
14
- - rvm: truffleruby
15
- - rvm: jruby-head
16
- env: JRUBY_OPTS="--debug -X+O"
17
- - rvm: ruby-head
18
- allow_failures:
19
- - rvm: ruby-head
20
- - rvm: jruby-head
21
- - rvm: truffleruby
data/Gemfile DELETED
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
4
-
5
- group :test do
6
- gem 'rack-test'
7
- end
data/README.md DELETED
@@ -1,143 +0,0 @@
1
- # Async::WebSocket
2
-
3
- A simple asynchronous websocket client/server implementation for [HTTP/1](https://tools.ietf.org/html/rfc6455) and [HTTP/2](https://tools.ietf.org/html/rfc8441).
4
-
5
- [![Build Status](https://secure.travis-ci.org/socketry/async-websocket.svg)](http://travis-ci.org/socketry/async-websocket)
6
- [![Code Climate](https://codeclimate.com/github/socketry/async-websocket.svg)](https://codeclimate.com/github/socketry/async-websocket)
7
- [![Coverage Status](https://coveralls.io/repos/socketry/async-websocket/badge.svg)](https://coveralls.io/r/socketry/async-websocket)
8
-
9
- [![WebSocket Client & Server for Ruby](https://img.youtube.com/vi/aHop4Yyjs_o/0.jpg)](https://www.youtube.com/watch?v=aHop4Yyjs_o)
10
-
11
- ## Installation
12
-
13
- Add this line to your application's Gemfile:
14
-
15
- gem 'async-websocket'
16
-
17
- And then execute:
18
-
19
- $ bundle
20
-
21
- Or install it yourself as:
22
-
23
- $ gem install async-websocket
24
-
25
- ## Usage
26
-
27
- There are [examples](examples/) which include:
28
-
29
- - [A command line chat client/server](examples/chat) which can read input from `stdin` and send messages to the server.
30
- - [A small MUD client/server](examples/mud) which uses JSON for communation between client/server.
31
- - [A utopia-based web application](examples/utopia) which uses a JavaScript client to connect to a web application server.
32
-
33
- ### Client Side with Async
34
-
35
- ```ruby
36
- #!/usr/bin/env ruby
37
-
38
- require 'async'
39
- require 'async/io/stream'
40
- require 'async/http/endpoint'
41
- require 'async/websocket/client'
42
-
43
- USER = ARGV.pop || "anonymous"
44
- URL = ARGV.pop || "http://localhost:7070"
45
-
46
- Async do |task|
47
- stdin = Async::IO::Stream.new(
48
- Async::IO::Generic.new($stdin)
49
- )
50
-
51
- endpoint = Async::HTTP::Endpoint.parse(URL)
52
-
53
- Async::WebSocket::Client.connect(endpoint) do |connection|
54
- input_task = task.async do
55
- while line = stdin.read_until("\n")
56
- connection.write({user: USER, text: line})
57
- connection.flush
58
- end
59
- end
60
-
61
- connection.write({
62
- user: USER,
63
- status: "connected",
64
- })
65
-
66
- while message = connection.read
67
- puts message.inspect
68
- end
69
- ensure
70
- input_task&.stop
71
- end
72
- end
73
- ```
74
-
75
- ### Server Side with Rack & Falcon
76
-
77
- ```ruby
78
- #!/usr/bin/env -S falcon serve --bind http://localhost:7070 --count 1 -c
79
-
80
- require 'async/websocket/adapters/rack'
81
- require 'set'
82
-
83
- $connections = Set.new
84
-
85
- run lambda {|env|
86
- Async::WebSocket::Adapters::Rack.open(env, protocols: ['ws']) do |connection|
87
- $connections << connection
88
-
89
- while message = connection.read
90
- $connections.each do |connection|
91
- connection.write(message)
92
- connection.flush
93
- end
94
- end
95
- ensure
96
- $connections.delete(connection)
97
- end or [200, {}, ["Hello World"]]
98
- }
99
- ```
100
-
101
- ### Force HTTP/1 Connection
102
-
103
- This forces the endpoint to connect using `HTTP/1.1`.
104
-
105
- ```ruby
106
- endpoint = Async::HTTP::Endpoint.parse("https://remote-server.com", alpn_protocols: Async::HTTP::Protocol::HTTP11.names)
107
-
108
- Async::WebSocket::Client.connect(endpoint) do ...
109
- ```
110
-
111
- You may want to use this if the server advertises `HTTP/2` but doesn't support `HTTP/2` for WebSocket connections.
112
-
113
- ## Contributing
114
-
115
- 1. Fork it
116
- 2. Create your feature branch (`git checkout -b my-new-feature`)
117
- 3. Commit your changes (`git commit -am 'Add some feature'`)
118
- 4. Push to the branch (`git push origin my-new-feature`)
119
- 5. Create new Pull Request
120
-
121
- ## License
122
-
123
- Released under the MIT license.
124
-
125
- Copyright, 2015, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
126
-
127
- Permission is hereby granted, free of charge, to any person obtaining a copy
128
- of this software and associated documentation files (the "Software"), to deal
129
- in the Software without restriction, including without limitation the rights
130
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
131
- copies of the Software, and to permit persons to whom the Software is
132
- furnished to do so, subject to the following conditions:
133
-
134
- The above copyright notice and this permission notice shall be included in
135
- all copies or substantial portions of the Software.
136
-
137
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
138
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
139
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
140
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
141
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
142
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
143
- THE SOFTWARE.