async-websocket 0.13.0 → 0.17.0

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.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/lib/async/websocket/adapters/rack.rb +7 -1
  3. data/lib/async/websocket/client.rb +39 -17
  4. data/lib/async/websocket/connect_request.rb +35 -17
  5. data/lib/async/websocket/connect_response.rb +2 -2
  6. data/lib/async/websocket/connection.rb +21 -2
  7. data/lib/async/websocket/request.rb +1 -1
  8. data/lib/async/websocket/response.rb +1 -1
  9. data/lib/async/websocket/server.rb +2 -0
  10. data/lib/async/websocket/upgrade_request.rb +9 -9
  11. data/lib/async/websocket/upgrade_response.rb +3 -3
  12. data/lib/async/websocket/version.rb +1 -1
  13. metadata +35 -102
  14. data/.editorconfig +0 -6
  15. data/.gitignore +0 -13
  16. data/.rspec +0 -3
  17. data/.travis.yml +0 -18
  18. data/Gemfile +0 -12
  19. data/README.md +0 -129
  20. data/Rakefile +0 -6
  21. data/async-websocket.gemspec +0 -29
  22. data/examples/chat/client.rb +0 -32
  23. data/examples/chat/config.ru +0 -113
  24. data/examples/chat/multi-client.rb +0 -81
  25. data/examples/mud/client.rb +0 -34
  26. data/examples/mud/config.ru +0 -142
  27. data/examples/rack/client.rb +0 -20
  28. data/examples/rack/config.ru +0 -14
  29. data/examples/utopia/.bowerrc +0 -4
  30. data/examples/utopia/.gitignore +0 -9
  31. data/examples/utopia/.rspec +0 -4
  32. data/examples/utopia/Gemfile +0 -33
  33. data/examples/utopia/Guardfile +0 -29
  34. data/examples/utopia/README.md +0 -16
  35. data/examples/utopia/Rakefile +0 -8
  36. data/examples/utopia/config.ru +0 -47
  37. data/examples/utopia/config/README.md +0 -7
  38. data/examples/utopia/config/environment.rb +0 -8
  39. data/examples/utopia/lib/readme.txt +0 -1
  40. data/examples/utopia/pages/_heading.xnode +0 -2
  41. data/examples/utopia/pages/_page.xnode +0 -30
  42. data/examples/utopia/pages/client/client.js +0 -28
  43. data/examples/utopia/pages/client/index.xnode +0 -8
  44. data/examples/utopia/pages/errors/exception.xnode +0 -5
  45. data/examples/utopia/pages/errors/file-not-found.xnode +0 -5
  46. data/examples/utopia/pages/links.yaml +0 -2
  47. data/examples/utopia/pages/server/controller.rb +0 -26
  48. data/examples/utopia/public/_static/icon.png +0 -0
  49. data/examples/utopia/public/_static/site.css +0 -205
  50. data/examples/utopia/public/_static/utopia-background.svg +0 -1
  51. data/examples/utopia/public/_static/utopia.svg +0 -1
  52. data/examples/utopia/public/readme.txt +0 -1
  53. data/examples/utopia/spec/spec_helper.rb +0 -31
  54. data/examples/utopia/spec/website_context.rb +0 -11
  55. data/examples/utopia/spec/website_spec.rb +0 -56
  56. data/examples/utopia/tasks/bower.rake +0 -45
  57. data/examples/utopia/tasks/deploy.rake +0 -13
  58. data/examples/utopia/tasks/development.rake +0 -34
  59. data/examples/utopia/tasks/environment.rake +0 -17
  60. data/examples/utopia/tasks/log.rake +0 -17
  61. data/examples/utopia/tasks/static.rake +0 -43
  62. data/spec/async/websocket/adapters/rack/client.rb +0 -38
  63. data/spec/async/websocket/adapters/rack/config.ru +0 -23
  64. data/spec/async/websocket/adapters/rack_spec.rb +0 -84
  65. data/spec/async/websocket/client_spec.rb +0 -48
  66. data/spec/async/websocket/connection_spec.rb +0 -34
  67. data/spec/async/websocket/server_examples.rb +0 -76
  68. data/spec/async/websocket/server_spec.rb +0 -31
  69. data/spec/async/websocket/upgrade.rb +0 -43
  70. data/spec/spec_helper.rb +0 -16
@@ -1,8 +0,0 @@
1
- <content:page>
2
- <content:heading>Client</content:heading>
3
-
4
- <script src="client.js?#{rand}"></script>
5
- <section id="response" style="border: 1px;"></section>
6
-
7
- <input id="chat" />
8
- </content:page>
@@ -1,5 +0,0 @@
1
- <content:page>
2
- <content:heading>Exception</content:heading>
3
-
4
- <p>It seems like something didn't quite work out as expected!</p>
5
- </content:page>
@@ -1,5 +0,0 @@
1
- <content:page>
2
- <content:heading>File Not Found</content:heading>
3
-
4
- <p>The file you requested is unfortunately not available at this time!</p>
5
- </content:page>
@@ -1,2 +0,0 @@
1
- errors:
2
- display: false
@@ -1,26 +0,0 @@
1
-
2
- prepend Actions
3
-
4
- require 'async/websocket/adapters/rack'
5
- require 'set'
6
-
7
- $connections = Set.new
8
-
9
- on 'connect' do |request|
10
- response = Async::WebSocket::Adapters::Rack.open(request.env) do |connection|
11
- $connections << connection
12
-
13
- while message = connection.read
14
- $connections.each do |connection|
15
- puts "Server sending message: #{message.inspect}"
16
- connection.write(message)
17
- end
18
- end
19
- ensure
20
- $connections.delete(connection)
21
- end
22
-
23
- Async.logger.info(self, request, response)
24
-
25
- respond?(response)
26
- end
@@ -1,205 +0,0 @@
1
-
2
- html {
3
- font-family: "PT Sans", Verdana, Helvetica, Arial, sans-serif;
4
- font-size: 16px;
5
- }
6
-
7
- pre {
8
- tab-size: 2;
9
- }
10
-
11
- @media (min-width: 40em) {
12
- html {
13
- font-size: 18px;
14
- }
15
-
16
- pre {
17
- tab-size: 4;
18
- }
19
- }
20
-
21
- @media (min-width: 80em) {
22
- html {
23
- font-size: 20px;
24
- }
25
-
26
- pre {
27
- tab-size: 4;
28
- }
29
- }
30
-
31
- body {
32
- padding: 0;
33
- margin: 0;
34
-
35
- background-color: #fafafa;
36
- }
37
-
38
- body > header {
39
- margin: 1rem 0 1rem 0;
40
-
41
- background-color: white;
42
-
43
- background-image: url(utopia-background.svg);
44
-
45
- box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
46
- }
47
-
48
- body > header img {
49
- display: block;
50
- margin: auto;
51
- height: 4rem;
52
- }
53
-
54
- p, ul, ol {
55
- color: #555;
56
- }
57
-
58
- p strong {
59
- color: #222;
60
- }
61
-
62
- h1, h2, h3, h4, h5, h6 {
63
- margin: 2rem 1rem 1rem 1rem;
64
- color: #4E8DD9;
65
- }
66
-
67
- h1 {
68
- margin-bottom: 4rem;
69
- }
70
-
71
- h2 {
72
- margin-top: 6rem;
73
- }
74
-
75
- img {
76
- border: none;
77
- }
78
-
79
- a {
80
- color: #33a;
81
- }
82
-
83
- a:hover {
84
- color: #55c;
85
- }
86
-
87
- p, ul, ol, dl, h3 {
88
- margin: 2rem;
89
- }
90
-
91
- li {
92
- margin: 0.2rem;
93
- }
94
-
95
- li > ul, li > ol {
96
- margin: 0;
97
- }
98
-
99
- pre {
100
- overflow: auto;
101
-
102
- padding: 1rem 2rem;
103
- font-size: 0.8rem;
104
-
105
- border-top: 1px solid #ccc;
106
- border-bottom: 1px solid #ccc;
107
-
108
- background-color: #eee;
109
- }
110
-
111
- h3 {
112
- border-bottom: 1px solid #ccf;
113
- }
114
-
115
- ul {
116
- margin-bottom: 1rem;
117
- }
118
-
119
- h2, h3, h4, h5, h6 {
120
- font-weight: normal;
121
- }
122
-
123
- body.front h1 {
124
- font-weight: normal;
125
- font-size: 300%;
126
- color: #F89432;
127
-
128
- text-align: center;
129
- }
130
-
131
- footer {
132
- text-align: right;
133
- margin: 2rem;
134
- font-size: 0.65rem;
135
- color: #aaa;
136
- }
137
-
138
- nav {
139
- position: absolute;
140
- margin: 2.5rem;
141
- font-size: 0.8rem;
142
- color: #aaa;
143
- }
144
-
145
- section.features {
146
- display: flex;
147
- flex-wrap: wrap;
148
- justify-content: space-around;
149
-
150
- margin: 1rem;
151
- }
152
-
153
- section.features > div {
154
- box-sizing: border-box;
155
-
156
- flex-basis: 20rem;
157
- flex-grow: 1;
158
-
159
- color: #171e42;
160
- margin: 1rem;
161
- padding: 1rem;
162
-
163
- padding-left: 3rem;
164
-
165
- position: relative;
166
- }
167
-
168
- section.features > div i {
169
- position: absolute;
170
- left: 0rem;
171
-
172
- font-size: 1.5rem;
173
- text-align: center;
174
-
175
- width: 3rem;
176
- color: #fafafa;
177
- text-shadow: 0px 0px 1px #000;
178
- }
179
-
180
- section.features p {
181
- margin: 0;
182
- maring-bottom: 1rem;
183
- font-size: 80%;
184
- }
185
-
186
- section.features h2 {
187
- margin: 0;
188
- font-size: 1.1rem;
189
- padding: 0;
190
- }
191
-
192
- form fieldset {
193
- border: 0;
194
- }
195
-
196
- form fieldset textarea {
197
- box-sizing: border-box;
198
-
199
- width: 100%;
200
- height: 10rem;
201
- }
202
-
203
- form fieldset.footer {
204
- text-align: right;
205
- }
@@ -1 +0,0 @@
1
- <?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg width="100%" height="100%" viewBox="0 0 10 80" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:1.41421;"><rect x="0" y="0" width="10" height="56" style="fill:#f79433;"/><rect x="0" y="56" width="10" height="24" style="fill:#4e8dd8;"/></svg>
@@ -1 +0,0 @@
1
- <?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg width="100%" height="100%" viewBox="0 0 420 80" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:1.41421;"><g><rect x="0" y="0" width="420" height="56" style="fill:#f79433;"/><rect x="0" y="56" width="420" height="24" style="fill:#4e8dd8;"/><g><path d="M75.145,70.819c2.37,-3.097 4.173,-6.921 5.111,-11.365c0.91,-4.318 1.498,-9.261 1.498,-14.692l0,-44.762l-62.754,0l0,44.762c0,2.628 0.244,5.333 0.407,8.035c0.168,2.782 0.674,5.515 1.345,8.118c0.68,2.644 1.739,5.173 3.067,7.517c1.363,2.405 3.263,4.526 5.609,6.303c2.319,1.755 5.245,3.163 8.677,4.172c1.617,0.478 3.416,1.093 5.354,1.093l13.856,0c3.071,0 5.797,-1.058 8.131,-2.001c4.042,-1.631 7.305,-4.049 9.699,-7.18Z" style="fill:#fff;fill-rule:nonzero;"/><path d="M151.481,18.701l0,-18.701l-62.754,-0.022l0,18.723l22.246,0l0.02,61.299l17.93,0l-0.02,-61.299l22.578,0Z" style="fill:#fff;fill-rule:nonzero;"/><path d="M229.926,39.999c0,-22.051 -16.979,-39.992 -37.852,-39.992c-20.872,0 -37.851,17.942 -37.851,39.992c0,22.054 16.979,39.994 37.851,39.994c20.873,0 37.852,-17.94 37.852,-39.994Z" style="fill:#fff;fill-rule:nonzero;"/><path d="M269.238,50.909c9.717,0 17.181,-2.066 22.183,-6.395c5.087,-4.399 7.667,-10.942 7.667,-19.575c0,-3.257 -0.393,-5.962 -1.167,-8.476c-0.778,-2.528 -1.883,-4.934 -3.281,-6.814c-1.401,-1.882 -3.098,-3.458 -5.045,-4.703c-1.895,-1.21 -4.003,-2.198 -6.264,-2.943c-2.239,-0.737 -4.64,-1.263 -7.139,-1.56c-2.464,-0.292 -5.016,-0.443 -7.587,-0.443l-29.468,0l0,80l17.93,0l0,-29.091l12.171,0Z" style="fill:#fff;fill-rule:nonzero;"/><rect x="304.879" y="0" width="17.93" height="80" style="fill:#fff;"/><path d="M362.589,0l-29.477,80l75.888,0l-31.247,-80l-15.164,0Z" style="fill:#fff;fill-rule:nonzero;"/></g></g></svg>
@@ -1 +0,0 @@
1
- This directory is required by Apache/Phusion Passenger and contains static assets that are typically served using sendfile.
@@ -1,31 +0,0 @@
1
-
2
- if ENV['COVERAGE']
3
- begin
4
- require 'simplecov'
5
-
6
- SimpleCov.start do
7
- add_filter "/spec/"
8
- end
9
-
10
- if ENV['TRAVIS']
11
- require 'coveralls'
12
- Coveralls.wear!
13
- end
14
- rescue LoadError
15
- warn "Could not load simplecov: #{$!}"
16
- end
17
- end
18
-
19
- require 'bundler/setup'
20
- require 'utopia'
21
-
22
- require 'async/rspec'
23
-
24
- RSpec.configure do |config|
25
- # Enable flags like --only-failures and --next-failure
26
- config.example_status_persistence_file_path = '.rspec_status'
27
-
28
- config.expect_with :rspec do |c|
29
- c.syntax = :expect
30
- end
31
- end
@@ -1,11 +0,0 @@
1
-
2
- require 'rack/test'
3
-
4
- RSpec.shared_context "website" do
5
- include Rack::Test::Methods
6
-
7
- let(:rackup_path) {File.expand_path('../config.ru', __dir__)}
8
- let(:rackup_directory) {File.dirname(rackup_path)}
9
-
10
- let(:app) {Rack::Builder.parse_file(rackup_path).first}
11
- end
@@ -1,56 +0,0 @@
1
-
2
- require_relative 'website_context'
3
-
4
- require 'falcon/server'
5
- require 'falcon/adapters/rack'
6
-
7
- require 'async/http/endpoint'
8
- require 'async/websocket/client'
9
-
10
- # Learn about best practice specs from http://betterspecs.org
11
- RSpec.describe "my website" do
12
- include_context "website"
13
-
14
- it "should have an accessible front page" do
15
- get "/"
16
-
17
- follow_redirect!
18
-
19
- expect(last_response.status).to be == 200
20
- end
21
-
22
- context "websockets" do
23
- include_context Async::RSpec::Reactor
24
-
25
- let(:endpoint) {Async::HTTP::Endpoint.parse("http://localhost:9282")}
26
- let(:server) {Falcon::Server.new(Falcon::Adapters::Rack.new(app), endpoint)}
27
-
28
- let(:hello_message) do
29
- {
30
- user: "test",
31
- text: "Hello World",
32
- }
33
- end
34
-
35
- let!(:server_task) do
36
- server_task = reactor.async do
37
- server.run
38
- end
39
- end
40
-
41
- after(:each) do
42
- server_task.stop
43
- end
44
-
45
- it "can connect to server" do
46
- endpoint.connect do |socket|
47
- connection = Async::WebSocket::Client.new(socket, "ws://localhost/server/connect")
48
-
49
- connection.write(hello_message)
50
-
51
- message = connection.read
52
- expect(message).to be == hello_message
53
- end
54
- end
55
- end
56
- end
@@ -1,45 +0,0 @@
1
-
2
- namespace :bower do
3
- desc 'Load the .bowerrc file and setup the environment for other tasks.'
4
- task :bowerrc do
5
- require 'json'
6
-
7
- bowerrc_path = SITE_ROOT + ".bowerrc"
8
- bowerrc = JSON.load(File.read(bowerrc_path))
9
-
10
- @bower_package_root = SITE_ROOT + bowerrc['directory']
11
- @bower_install_root = SITE_ROOT + bowerrc['public']
12
- @bower_install_method = (bowerrc['install'] || :copy).to_sym
13
- end
14
-
15
- desc 'Update the bower packages and link into the public directory.'
16
- task :update => :bowerrc do
17
- require 'fileutils'
18
- require 'utopia/path'
19
-
20
- #sh %W{bower update}
21
-
22
- @bower_package_root.children.select(&:directory?).collect(&:basename).each do |package_directory|
23
- install_path = @bower_install_root + package_directory
24
- package_path = @bower_package_root + package_directory
25
- dist_path = package_path + 'dist'
26
-
27
- FileUtils::Verbose.rm_rf install_path
28
- FileUtils::Verbose.mkpath(install_path.dirname)
29
-
30
- # If a package has a dist directory, we only symlink that... otherwise we have to do the entire package, and hope that bower's ignore was setup correctly:
31
- if File.exist? dist_path
32
- link_path = Utopia::Path.shortest_path(dist_path, install_path)
33
- else
34
- link_path = Utopia::Path.shortest_path(package_path, install_path)
35
- end
36
-
37
- if @bower_install_method == :symlink
38
- # This is useful for some
39
- FileUtils::Verbose.ln_s link_path, install_path
40
- else
41
- FileUtils::Verbose.cp_r File.expand_path(link_path, install_path), install_path
42
- end
43
- end
44
- end
45
- end
@@ -1,13 +0,0 @@
1
-
2
- desc 'Run by git post-update hook when deployed to a web server'
3
- task :deploy do
4
- # This task is typiclly run after the site is updated but before the server is restarted.
5
- end
6
-
7
- desc 'Restart the application server'
8
- task :restart do
9
- # This task is run after the deployment task above.
10
- if passenger_config = `which passenger-config`.chomp!
11
- sh(passenger_config, 'restart-app', '--ignore-passenger-not-running', SITE_ROOT.to_s)
12
- end
13
- end
@@ -1,34 +0,0 @@
1
-
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:test) do |task|
5
- task.rspec_opts = %w{--require simplecov} if ENV['COVERAGE']
6
- end
7
-
8
- task :coverage do
9
- ENV['COVERAGE'] = 'y'
10
- end
11
-
12
- desc 'Start the development server.'
13
- task :server => :environment do
14
- exec('guard', '-g', 'development')
15
- end
16
-
17
- desc 'Start the development environment which includes web server and tests.'
18
- task :development => :environment do
19
- exec('guard', '-g', 'development,test')
20
- end
21
-
22
- desc 'Start an interactive console for your web application'
23
- task :console => :environment do
24
- require 'pry'
25
- require 'rack/test'
26
-
27
- include Rack::Test::Methods
28
-
29
- def app
30
- @app ||= Rack::Builder.parse_file(SITE_ROOT + 'config.ru').first
31
- end
32
-
33
- Pry.start
34
- end