async-websocket 0.13.0 → 0.13.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: 37e8a4add65ab76660e26f32c32f175127010ea482bcc4ec667a33599537955d
4
- data.tar.gz: 1cf93bfb5264891e5b500c7c9d97462a481d6f5947bd3461b1431c2b4b289e3f
3
+ metadata.gz: 237b59048febd538e6112ea06b520c154386d057bd3b58a22bb153d45cd3209f
4
+ data.tar.gz: '0966a1666e31463adb1c2975f7e72534c7a8003794825ab94c24c3d5d02223e7'
5
5
  SHA512:
6
- metadata.gz: 9fc18c9154780780e29ef16a233b7386fa9cc915f94d1e1bc573cdccc3fdc835b7ad778a5c686d14ac4e4b156e77e84ff3bed810afc02feb1bc326ceae8aa237
7
- data.tar.gz: 92332727953f7660154439cf5e86524a498ce335b666728f74bca9b22e6ba8f61dfa7b7bc4f6e66b702ff83de5c060b8c2189b7d0831c5fbb98a95e8b8669f32
6
+ metadata.gz: 7e25c38a3d25b98209d3999e803f031cb216dd1ccd47f1c2af92fd75cab7859d888ee9fd79873aab8d41d9d6e1ff4bd3bf64addcba74bad619613c948ec17e89
7
+ data.tar.gz: a7284a36f8525415327177da55e83d35001f329d50b4b1843e4cd0b4d2488b17da26559df0248e493bea86ac163e0f3434113a6b76e4d1c9a16978e3c4118a41
@@ -0,0 +1,3 @@
1
+ # The Journey to One Million
2
+
3
+
@@ -6,7 +6,7 @@ require 'async/http/endpoint'
6
6
  require_relative '../../lib/async/websocket/client'
7
7
 
8
8
  USER = ARGV.pop || "anonymous"
9
- URL = ARGV.pop || "http://127.0.0.1:8080"
9
+ URL = ARGV.pop || "https://localhost:8080"
10
10
  ENDPOINT = Async::HTTP::Endpoint.parse(URL)
11
11
 
12
12
  Async do |task|
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env -S falcon serve --bind http://127.0.0.1:8080 --count 1 -c
1
+ #!/usr/bin/env -S falcon serve --bind https://localhost:8080 --count 1 -c
2
2
 
3
3
  require_relative '../../lib/async/websocket/adapters/rack'
4
4
  require 'async/clock'
@@ -18,7 +18,7 @@ class Command < Samovar::Command
18
18
  options do
19
19
  option "-c/--count <integer>", "The total number of connections to make.", default: 1000, type: Integer
20
20
  option "--bind <address>", "The local address to bind to before making a connection."
21
- option "--connect <string>", "The remote server to connect to.", default: "http://127.0.0.1:8080"
21
+ option "--connect <string>", "The remote server to connect to.", default: "https://localhost:8080"
22
22
 
23
23
  option "-s/--semaphore <integer>", "The number of simultaneous connections to perform."
24
24
  end
@@ -24,6 +24,8 @@ require 'protocol/http/request'
24
24
  require 'protocol/http/headers'
25
25
  require 'protocol/websocket/headers'
26
26
 
27
+ require 'async/http/body/stream'
28
+
27
29
  module Async
28
30
  module WebSocket
29
31
  # This is required for HTTP/1.x to upgrade the connection to the WebSocket protocol.
@@ -32,12 +34,15 @@ module Async
32
34
  include ::Protocol::WebSocket::Headers
33
35
 
34
36
  class Wrapper
35
- def initialize(body, response)
36
- @body = body
37
+ def initialize(output, response)
38
+ @output = output
39
+ @body = output
37
40
  @response = response
38
41
  @stream = nil
39
42
  end
40
43
 
44
+ attr_accessor :body
45
+
41
46
  def stream?
42
47
  @response.success?
43
48
  end
@@ -54,14 +59,12 @@ module Async
54
59
  true
55
60
  end
56
61
 
57
- attr_accessor :body
58
-
59
62
  def protocol
60
63
  @response.protocol
61
64
  end
62
65
 
63
66
  def stream
64
- @stream ||= Async::HTTP::Body::Stream.new(@response.body, @body)
67
+ @stream ||= Async::HTTP::Body::Stream.new(@response.body, @output)
65
68
  end
66
69
  end
67
70
 
@@ -82,7 +85,7 @@ module Async
82
85
  end
83
86
 
84
87
  def call(connection)
85
- Wrapper.new(@body, super)
88
+ Wrapper.new(body, super)
86
89
  end
87
90
  end
88
91
  end
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Async
22
22
  module WebSocket
23
- VERSION = "0.13.0"
23
+ VERSION = "0.13.1"
24
24
  end
25
25
  end
@@ -29,7 +29,7 @@ RSpec.shared_context Async::WebSocket::Server do
29
29
  include_context Async::RSpec::Reactor
30
30
 
31
31
  let(:protocol) {described_class}
32
- let(:endpoint) {Async::HTTP::Endpoint.parse('http://127.0.0.1:8008', reuse_port: true)}
32
+ let(:endpoint) {Async::HTTP::Endpoint.parse('http://127.0.0.1:8008')}
33
33
 
34
34
  let!(:client) {Async::WebSocket::Client.open(endpoint, protocol)}
35
35
 
@@ -49,6 +49,8 @@ RSpec.shared_context Async::WebSocket::Server do
49
49
  let(:handler) {Async::WebSocket::Connection}
50
50
  let(:headers) {Array.new}
51
51
 
52
+ let(:message) {["Hello World"]}
53
+
52
54
  let(:server) do
53
55
  Async::HTTP::Server.for(endpoint, protocol) do |request|
54
56
  if Async::WebSocket::Request.websocket?(request)
@@ -57,6 +59,8 @@ RSpec.shared_context Async::WebSocket::Server do
57
59
 
58
60
  connection = handler.call(framer)
59
61
 
62
+ connection.write(message)
63
+
60
64
  connection.close
61
65
  end
62
66
  else
@@ -68,6 +72,7 @@ RSpec.shared_context Async::WebSocket::Server do
68
72
  it "can establish connection" do
69
73
  connection = client.connect("/server")
70
74
 
75
+ expect(connection.read).to be == message
71
76
  expect(connection.read).to be_nil
72
77
  expect(connection).to be_closed
73
78
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-websocket
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-22 00:00:00.000000000 Z
11
+ date: 2019-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-io
@@ -151,6 +151,7 @@ files:
151
151
  - README.md
152
152
  - Rakefile
153
153
  - async-websocket.gemspec
154
+ - examples/chat/README.md
154
155
  - examples/chat/client.rb
155
156
  - examples/chat/config.ru
156
157
  - examples/chat/multi-client.rb
@@ -233,7 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
233
234
  - !ruby/object:Gem::Version
234
235
  version: '0'
235
236
  requirements: []
236
- rubygems_version: 3.0.2
237
+ rubygems_version: 3.0.3
237
238
  signing_key:
238
239
  specification_version: 4
239
240
  summary: An async websocket library on top of websocket-driver.