websocket-client-simple 0.3.1 → 0.8.0

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: 6d8831f5be8aa53190a5219b4a245b56722cdc421572d5670958e82962d4fbb1
4
- data.tar.gz: 8f59c91e11fa7e672ab5b48f1d1d447a215af4be3891c68f36214a0f893254a0
3
+ metadata.gz: 7589c208daf3fa057d52cc788dafa63401a1c71dd20413d95e8eae0b42a09251
4
+ data.tar.gz: 53a1bed22541edce6f7d64ae140873a8d6b454f854f39c9a7a85ac4bcc78313b
5
5
  SHA512:
6
- metadata.gz: eedeaff30cd560fd44127254696e9a7ee4b5a44fb38fa1d59274a90f744118e2b92c43f6a9cad245f1da431a69f94fc13274ff5dd66d7275261187d0d349481c
7
- data.tar.gz: 20c709ce576c3ee020b79f09082d9ba01a0eb28837e0fcf7afedef851ccb63c026e2502e5d236a0a2490cfc4241dc36d2e2c792ef10cc1a24ff5c969e9c53260
6
+ metadata.gz: 2c80ac0a53fde73ed53bbe6149b911ffbe053f056d87423700dd58fc4bade8a06aa630ec48b0e6018f6ab7d093e2394d590f407e00c019629061b24f1e05ab6f
7
+ data.tar.gz: fa4c287824fafab4bbca6abc7c23c1a3ca8bb0ff1c0381614f2e579605951870bf2c2850c48bb0c599ae1bb20cc81a319202a89aebe93691e57dccad2bdd6f98
@@ -9,13 +9,13 @@ on:
9
9
  - cron: "0 0 * * 6" # At 00:00 on Saturday
10
10
  jobs:
11
11
  test:
12
- runs-on: ubuntu-20.04
12
+ runs-on: ubuntu-22.04
13
13
  strategy:
14
14
  matrix:
15
- ruby: ["3.1", "3.0", "2.7", "2.6"]
15
+ ruby: ["3.2", "3.1", "3.0", "2.7", "2.6"]
16
16
  name: Ruby ${{ matrix.ruby }}
17
17
  steps:
18
- - uses: actions/checkout@v2
18
+ - uses: actions/checkout@v3
19
19
  - uses: ruby/setup-ruby@v1
20
20
  with:
21
21
  ruby-version: ${{ matrix.ruby }}
data/CHANGELOG.md ADDED
@@ -0,0 +1,88 @@
1
+ # Changelog
2
+
3
+ ## Not yet released
4
+
5
+ ## 0.8.0 - 2023-08-08
6
+ * Set `WebSocket.should_raise = true` https://github.com/ruby-jp/websocket-client-simple/pull/25 by @jlaffaye
7
+
8
+ ## 0.7.0 - 2023-08-04
9
+ * Expose add accessor `Client#thread` #22 by @jlaffaye
10
+ * Rewrite changelog as a Markdown
11
+
12
+ ## 0.6.1 - 2023-03-10
13
+ * Make `#open?` safe to use when `@handshake` is `nil` #20 by @cyberarm
14
+
15
+ ## 0.6.0 - 2022-09-22
16
+ * Add option `cert_store` for passing cert store to SSLSocket context #12 by @DerekStride
17
+ * Set `OpenSSL::SSL::SSLSocket#sync_close` to `true` #12 by @DerekStride
18
+
19
+ ## 0.5.1 - 2022-01-01
20
+ * Add `closed?` method to `WebSocket::Client::Simple` #8 by @fuyuton
21
+ * rescue when `OpenSSL::SSL::SSLError` raised #10 by @fuyuton
22
+
23
+ ## 0.5.0 - 2021-12-31
24
+ * Change TLS context defaults to system's default. The previous defaults were `ssl_version=SSLv23` and `verify_mode=VERIFY_NONE`, which are insecure nowadays. #5
25
+ * thank you for contributing @eagletmt
26
+ * Made the necessary changes to use SNI. #6
27
+ * thank you for contributing @fuyuton
28
+
29
+ ## 0.4.0 - 2021-12-30
30
+ * Drop support of ruby 2.5 or older versions as explicit.
31
+
32
+ ## 0.3.1 - 2021-12-30
33
+ * The development of this repository has moved to https://github.com/ruby-jp/websocket-client-simple
34
+
35
+ ## 0.3.0 - 2016-12-30
36
+ * `connect` method runs a given block before connecting WebSocket [#12](https://github.com/shokai/websocket-client-simple/issues/12)
37
+ * thank you for suggestion @codekitchen
38
+
39
+ ## 0.2.5 - 2016-02-18
40
+ * bugfixed sending when broken pipe [#15](https://github.com/shokai/websocket-client-simple/pull/15)
41
+ * add `:verify_mode` option for SSL Context [#14](https://github.com/shokai/websocket-client-simple/pull/14)
42
+ * thank you for contributing @michaelvilensky
43
+
44
+ ## 0.2.4 - 2015-11-12
45
+ * support handshake headers [#11](https://github.com/shokai/websocket-client-simple/pull/11)
46
+ * thank you for contributing @mathieugagne
47
+
48
+ ## 0.2.3 - 2015-10-26
49
+ * kill thread at end of method [#10](https://github.com/shokai/websocket-client-simple/pull/10)
50
+ * thank you for contributing @hansy
51
+
52
+ ## 0.2.2 - 2014-11-18
53
+ * bugfix socket reading
54
+
55
+ ## 0.2.0 - 2014-06-07
56
+ * SSL support with `wss://` and `https://` scheme [#6](https://github.com/shokai/websocket-client-simple/pull/6)
57
+ * thank you for contributing @mallowlabs
58
+
59
+ ## 0.1.0 - 2014-05-08
60
+ * add accessor `Client#handshake` [#5](https://github.com/shokai/websocket-client-simple/issues/5)
61
+ * bugfix socket reading
62
+
63
+ ## 0.0.9 - 2014-04-03
64
+ * emit `error` in receive thread
65
+ * rescue only `Errno::EPIPE`, not all Errors
66
+
67
+ ## 0.0.8 - 2014-01-29
68
+ * bugfix `Client#close` #4
69
+
70
+ ## 0.0.7 - 2014-01-29
71
+ * send CLOSE frame in `Client#close` [#4](https://github.com/shokai/websocket-client-simple/issues/4)
72
+ ## 0.0.6 - 2014-01-17
73
+ * add function `Client#open?`
74
+
75
+ ## 0.0.5 - 2013-03-23
76
+ * kill read thread on close
77
+
78
+ ## 0.0.4 - 2013-03-23
79
+ * fix sample and README
80
+
81
+ ## 0.0.3 - 2013-03-23
82
+ * `:type => :text` option in send
83
+
84
+ ## 0.0.2 - 2013-03-22
85
+ * remove unnecessary sleep
86
+
87
+ ## 0.0.1 - 2013-03-22
88
+ * release
data/README.md CHANGED
@@ -16,7 +16,6 @@ Installation
16
16
  Usage
17
17
  -----
18
18
  ```ruby
19
- require 'rubygems'
20
19
  require 'websocket-client-simple'
21
20
 
22
21
  ws = WebSocket::Client::Simple.connect 'ws://example.com:8888'
@@ -60,7 +59,7 @@ end
60
59
 
61
60
  Sample
62
61
  ------
63
- [websocket chat](https://github.com/shokai/websocket-client-simple/tree/master/sample)
62
+ [websocket chat](https://github.com/ruby-jp/websocket-client-simple/tree/master/sample)
64
63
 
65
64
 
66
65
  Test
@@ -11,7 +11,7 @@ module WebSocket
11
11
 
12
12
  class Client
13
13
  include EventEmitter
14
- attr_reader :url, :handshake
14
+ attr_reader :url, :handshake, :thread
15
15
 
16
16
  def connect(url, options={})
17
17
  return if @socket
@@ -21,14 +21,17 @@ module WebSocket
21
21
  uri.port || (uri.scheme == 'wss' ? 443 : 80))
22
22
  if ['https', 'wss'].include? uri.scheme
23
23
  ctx = OpenSSL::SSL::SSLContext.new
24
- ctx.ssl_version = options[:ssl_version] || 'SSLv23'
25
- ctx.verify_mode = options[:verify_mode] || OpenSSL::SSL::VERIFY_NONE #use VERIFY_PEER for verification
26
- cert_store = OpenSSL::X509::Store.new
24
+ ctx.ssl_version = options[:ssl_version] if options[:ssl_version]
25
+ ctx.verify_mode = options[:verify_mode] if options[:verify_mode]
26
+ cert_store = options[:cert_store] || OpenSSL::X509::Store.new
27
27
  cert_store.set_default_paths
28
28
  ctx.cert_store = cert_store
29
29
  @socket = ::OpenSSL::SSL::SSLSocket.new(@socket, ctx)
30
+ @socket.sync_close = true
31
+ @socket.hostname = uri.host
30
32
  @socket.connect
31
33
  end
34
+ ::WebSocket.should_raise = true
32
35
  @handshake = ::WebSocket::Handshake::Client.new :url => url, :headers => options[:headers]
33
36
  @handshaked = false
34
37
  @pipe_broken = false
@@ -76,6 +79,9 @@ module WebSocket
76
79
  rescue Errno::EPIPE => e
77
80
  @pipe_broken = true
78
81
  emit :__close, e
82
+ rescue OpenSSL::SSL::SSLError => e
83
+ @pipe_broken = true
84
+ emit :__close, e
79
85
  end
80
86
  end
81
87
 
@@ -92,7 +98,11 @@ module WebSocket
92
98
  end
93
99
 
94
100
  def open?
95
- @handshake.finished? and !@closed
101
+ @handshake&.finished? and !@closed
102
+ end
103
+
104
+ def closed?
105
+ @closed
96
106
  end
97
107
 
98
108
  end
@@ -1,7 +1,7 @@
1
1
  module WebSocket
2
2
  module Client
3
3
  module Simple
4
- VERSION = "0.3.1"
4
+ VERSION = "0.8.0"
5
5
  end
6
6
  end
7
7
  end
data/sample/client.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  $:.unshift File.expand_path '../lib', File.dirname(__FILE__)
3
- require 'rubygems'
4
3
  require 'websocket-client-simple'
5
4
 
6
5
  puts "websocket-client-simple v#{WebSocket::Client::Simple::VERSION}"
@@ -16,7 +16,7 @@
16
16
  <ul id="chat"></ul>
17
17
  <div id="footer">
18
18
  <hr>
19
- <a href="https://github.com/shokai/websocket-client-simple">https://github.com/shokai/websocket-client-simple</a>
19
+ <a href="https://github.com/ruby-jp/websocket-client-simple">https://github.com/ruby-jp/websocket-client-simple</a>
20
20
  </div>
21
21
  </body>
22
22
  </html>
@@ -1,11 +1,11 @@
1
1
  require File.expand_path 'test_helper', File.dirname(__FILE__)
2
2
 
3
- class TestWebSocketClientSimple < MiniTest::Test
4
-
3
+ class TestWebSocketClientSimple < Minitest::Test
4
+
5
5
  def test_onopen
6
-
6
+
7
7
  EM::run{
8
-
8
+
9
9
  EchoServer.start
10
10
 
11
11
  res = nil
@@ -27,7 +27,7 @@ class TestWebSocketClientSimple < MiniTest::Test
27
27
  EM::stop_event_loop
28
28
  end
29
29
  }
30
-
30
+
31
31
  end
32
-
32
+
33
33
  end
@@ -1,6 +1,6 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- class TestWebSocketClientSimple < MiniTest::Test
3
+ class TestWebSocketClientSimple < Minitest::Test
4
4
 
5
5
  def test_echo
6
6
  msgs = ['foo','bar','baz']
@@ -11,11 +11,12 @@ Gem::Specification.new do |spec|
11
11
  spec.summary = spec.description
12
12
  spec.homepage = "https://github.com/ruby-jp/websocket-client-simple"
13
13
  spec.license = "MIT"
14
+ spec.required_ruby_version = '>= 2.6.9'
14
15
 
15
16
  if spec.respond_to?(:metadata)
16
17
  spec.metadata["homepage_uri"] = spec.homepage
17
18
  spec.metadata["source_code_uri"] = spec.homepage
18
- spec.metadata["changelog_uri"] = "https://github.com/ruby-jp/websocket-client-simple/blob/master/History.txt"
19
+ spec.metadata["changelog_uri"] = "https://github.com/ruby-jp/websocket-client-simple/blob/master/CHANGELOG.md"
19
20
  end
20
21
 
21
22
  spec.post_install_message = "The development of this gem has moved to #{spec.homepage}."
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: websocket-client-simple
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sho Hashimoto
8
8
  - Yusuke Nakamura
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-12-30 00:00:00.000000000 Z
12
+ date: 2023-08-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -119,8 +119,8 @@ extra_rdoc_files: []
119
119
  files:
120
120
  - ".github/workflows/test.yml"
121
121
  - ".gitignore"
122
+ - CHANGELOG.md
122
123
  - Gemfile
123
- - History.txt
124
124
  - LICENSE.txt
125
125
  - README.md
126
126
  - Rakefile
@@ -142,7 +142,7 @@ licenses:
142
142
  metadata:
143
143
  homepage_uri: https://github.com/ruby-jp/websocket-client-simple
144
144
  source_code_uri: https://github.com/ruby-jp/websocket-client-simple
145
- changelog_uri: https://github.com/ruby-jp/websocket-client-simple/blob/master/History.txt
145
+ changelog_uri: https://github.com/ruby-jp/websocket-client-simple/blob/master/CHANGELOG.md
146
146
  post_install_message: The development of this gem has moved to https://github.com/ruby-jp/websocket-client-simple.
147
147
  rdoc_options: []
148
148
  require_paths:
@@ -151,15 +151,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
151
151
  requirements:
152
152
  - - ">="
153
153
  - !ruby/object:Gem::Version
154
- version: '0'
154
+ version: 2.6.9
155
155
  required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - ">="
158
158
  - !ruby/object:Gem::Version
159
159
  version: '0'
160
160
  requirements: []
161
- rubygems_version: 3.1.6
162
- signing_key:
161
+ rubygems_version: 3.3.7
162
+ signing_key:
163
163
  specification_version: 4
164
164
  summary: Simple WebSocket Client for Ruby
165
165
  test_files:
data/History.txt DELETED
@@ -1,80 +0,0 @@
1
- === 0.3.1 2021-12-30
2
-
3
- * The development of this repository has moved to https://github.com/ruby-jp/websocket-client-simple
4
-
5
- === 0.3.0 2016-02-20
6
-
7
- * "connect" method runs a given block before connecting WebSocket #12
8
- * thank you for suggestion @codekitchen
9
-
10
- === 0.2.5 2016-02-18
11
-
12
- * bugfixed sending when broken pipe #15
13
- * add :verify_mode option for SSL Context #14
14
- * thank you for contributing @michaelvilensky
15
-
16
- === 0.2.4 2015-11-12
17
-
18
- * support handshake headers #11
19
- * thank you for contributing @mathieugagne
20
-
21
- === 0.2.3 2015-10-26
22
-
23
- * kill thread at end of method
24
- * thank you for contributing @hansy
25
-
26
- === 0.2.2 2014-11-18
27
-
28
- * add :ssl_version option to specify version of SSL/TLS
29
- * thank you for contributing @tonybyrne
30
-
31
- === 0.2.1 2014-10-19
32
-
33
- * bugfix socket reading
34
-
35
- === 0.2.0 2014-06-07
36
-
37
- * SSL support with wss:// and https:// scheme
38
- * thank you for contributing @mallowlabs
39
-
40
- === 0.1.0 2014-05-08
41
-
42
- * add accessor Client#handshake #5
43
- * bugfix socket reading
44
-
45
- === 0.0.9 2014-04-03
46
-
47
- * emit "error" in receive thread
48
- * rescue only Errno::EPIPE, not all Errors
49
-
50
- === 0.0.8 2014-01-29
51
-
52
- * bugfix Client#close #4
53
-
54
- === 0.0.7 2014-01-29
55
-
56
- * send CLOSE frame in Client#close #4
57
-
58
- === 0.0.6 2014-01-17
59
-
60
- * add function Client#open?
61
-
62
- === 0.0.5 2013-03-23
63
-
64
- * kill read thread on close
65
-
66
- === 0.0.4 2013-03-23
67
-
68
- * fix sample and README
69
-
70
- === 0.0.3 2013-03-23
71
-
72
- * :type => :text option in send
73
-
74
- === 0.0.2 2013-03-22
75
-
76
- * remove unnecessary sleep
77
-
78
- === 0.0.1 2013-03-22
79
-
80
- * release