ws_client 0.1.5 → 0.1.6

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
  SHA1:
3
- metadata.gz: 9832be21bf9d0c9e3ad56f8316e9fad17f355854
4
- data.tar.gz: 9dd2d13ee3d1d3317669c2ca95fe747f4786deaa
3
+ metadata.gz: ab35da491f4c5d26b8afd50f14e0f195c44db4a2
4
+ data.tar.gz: db726294b252fd3494b1c80c91b92f5e1c231032
5
5
  SHA512:
6
- metadata.gz: c490feb80923e1331596ab66fbcc602baa5a98be2146706c74b3fd77c8f9892ae44c24aeef19280f7150ec4b487113ceca0c92972dd2f203a1a4f34ef7e8a250
7
- data.tar.gz: fe962b0b415adfe7e6dc366079ea42ebb2944be10854d750e3299d4bcb96d5bfd54b99df0cd7cfe1f6fbed17f8bd0c88ddcd9d2453bfe797d6ac41182db5bc9c
6
+ metadata.gz: 9c0d8d40e04d5f255c31b7417efbe4af44126315fabe84ba3abf9414254d26d0f5710e803cdfed148b26cda6cb009535a33c3e232b15ae004f4065ac23169ffb
7
+ data.tar.gz: 64f09b2ec2e11af8744950987dee3596516f0fe1b90c9317c698b5331422f040b30f0cafdecaf9f66db1aa92a4e925745e3c7e3738ea6de941ee78348b0823b2
@@ -1,3 +1,3 @@
1
1
  module WsClient
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
data/lib/ws_client.rb CHANGED
@@ -58,6 +58,11 @@ module WsClient
58
58
  @closed = false
59
59
 
60
60
  handshake
61
+ rescue OpenSSL::SSL::SSLError, EOFError
62
+ # Re-use the socket cleanup logic if we have a connect failure.
63
+ @pipe_broken = true
64
+ close
65
+ raise
61
66
  end
62
67
 
63
68
  def reconnect
@@ -172,21 +177,27 @@ module WsClient
172
177
 
173
178
  def write_data(data, opt)
174
179
  frame = ::WebSocket::Frame::Outgoing::Client.new(:data => data, :type => opt[:type], :version => @handshake.version)
180
+ frame_str = frame.to_s
175
181
 
176
- begin
177
- @socket.write_nonblock(frame.to_s)
178
- rescue IO::WaitReadable
179
- IO.select([@socket]) # OpenSSL needs to read internally
180
- retry
181
- rescue IO::WaitWritable, Errno::EINTR
182
- IO.select(nil, [@socket])
183
- retry
184
- rescue Errno::EPIPE => e
185
- @pipe_broken = true
186
- close
187
- rescue => e
188
- close
189
- emit :error, e
182
+ loop do
183
+ break if frame_str.empty? || @closed
184
+
185
+ begin
186
+ num_bytes_written = @socket.write_nonblock(frame_str)
187
+ frame_str = frame_str[num_bytes_written..-1]
188
+ rescue IO::WaitReadable
189
+ IO.select([@socket]) # OpenSSL needs to read internally
190
+ retry
191
+ rescue IO::WaitWritable, Errno::EINTR
192
+ IO.select(nil, [@socket])
193
+ retry
194
+ rescue Errno::EPIPE => e
195
+ @pipe_broken = true
196
+ close
197
+ rescue => e
198
+ close
199
+ emit :error, e
200
+ end
190
201
  end
191
202
  end
192
203
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ws_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Dewitt
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-08-26 00:00:00.000000000 Z
12
+ date: 2016-08-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler