websocket-client-simple 0.5.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +3 -3
- data/CHANGELOG.md +88 -0
- data/README.md +1 -2
- data/lib/websocket-client-simple/client.rb +12 -3
- data/lib/websocket-client-simple/version.rb +1 -1
- data/sample/client.rb +0 -1
- data/sample/webbrowser/index.html +1 -1
- data/test/test_connect_block.rb +6 -6
- data/test/test_websocket_client_simple.rb +1 -1
- data/websocket-client-simple.gemspec +1 -1
- metadata +7 -7
- data/History.txt +0 -93
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7589c208daf3fa057d52cc788dafa63401a1c71dd20413d95e8eae0b42a09251
|
4
|
+
data.tar.gz: 53a1bed22541edce6f7d64ae140873a8d6b454f854f39c9a7a85ac4bcc78313b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c80ac0a53fde73ed53bbe6149b911ffbe053f056d87423700dd58fc4bade8a06aa630ec48b0e6018f6ab7d093e2394d590f407e00c019629061b24f1e05ab6f
|
7
|
+
data.tar.gz: fa4c287824fafab4bbca6abc7c23c1a3ca8bb0ff1c0381614f2e579605951870bf2c2850c48bb0c599ae1bb20cc81a319202a89aebe93691e57dccad2bdd6f98
|
data/.github/workflows/test.yml
CHANGED
@@ -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-
|
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@
|
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/
|
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
|
@@ -23,13 +23,15 @@ module WebSocket
|
|
23
23
|
ctx = OpenSSL::SSL::SSLContext.new
|
24
24
|
ctx.ssl_version = options[:ssl_version] if options[:ssl_version]
|
25
25
|
ctx.verify_mode = options[:verify_mode] if options[:verify_mode]
|
26
|
-
cert_store = OpenSSL::X509::Store.new
|
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
|
30
31
|
@socket.hostname = uri.host
|
31
32
|
@socket.connect
|
32
33
|
end
|
34
|
+
::WebSocket.should_raise = true
|
33
35
|
@handshake = ::WebSocket::Handshake::Client.new :url => url, :headers => options[:headers]
|
34
36
|
@handshaked = false
|
35
37
|
@pipe_broken = false
|
@@ -77,6 +79,9 @@ module WebSocket
|
|
77
79
|
rescue Errno::EPIPE => e
|
78
80
|
@pipe_broken = true
|
79
81
|
emit :__close, e
|
82
|
+
rescue OpenSSL::SSL::SSLError => e
|
83
|
+
@pipe_broken = true
|
84
|
+
emit :__close, e
|
80
85
|
end
|
81
86
|
end
|
82
87
|
|
@@ -93,7 +98,11 @@ module WebSocket
|
|
93
98
|
end
|
94
99
|
|
95
100
|
def open?
|
96
|
-
@handshake
|
101
|
+
@handshake&.finished? and !@closed
|
102
|
+
end
|
103
|
+
|
104
|
+
def closed?
|
105
|
+
@closed
|
97
106
|
end
|
98
107
|
|
99
108
|
end
|
data/sample/client.rb
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
<ul id="chat"></ul>
|
17
17
|
<div id="footer">
|
18
18
|
<hr>
|
19
|
-
<a href="https://github.com/
|
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>
|
data/test/test_connect_block.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
require File.expand_path 'test_helper', File.dirname(__FILE__)
|
2
2
|
|
3
|
-
class TestWebSocketClientSimple <
|
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
|
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
16
16
|
if spec.respond_to?(:metadata)
|
17
17
|
spec.metadata["homepage_uri"] = spec.homepage
|
18
18
|
spec.metadata["source_code_uri"] = spec.homepage
|
19
|
-
spec.metadata["changelog_uri"] = "https://github.com/ruby-jp/websocket-client-simple/blob/master/
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/ruby-jp/websocket-client-simple/blob/master/CHANGELOG.md"
|
20
20
|
end
|
21
21
|
|
22
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.
|
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:
|
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/
|
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:
|
@@ -158,8 +158,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
158
|
- !ruby/object:Gem::Version
|
159
159
|
version: '0'
|
160
160
|
requirements: []
|
161
|
-
rubygems_version: 3.
|
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,93 +0,0 @@
|
|
1
|
-
=== Not yet released
|
2
|
-
|
3
|
-
=== 0.5.0 2021-12-31
|
4
|
-
|
5
|
-
* 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
|
6
|
-
* thank you for contributing @eagletmt
|
7
|
-
* Made the necessary changes to use SNI. #6
|
8
|
-
* thank you for contributing @fuyuton
|
9
|
-
|
10
|
-
=== 0.4.0 2021-12-30
|
11
|
-
|
12
|
-
* Drop support of ruby 2.5 or older versions as explicit.
|
13
|
-
|
14
|
-
=== 0.3.1 2021-12-30
|
15
|
-
|
16
|
-
* The development of this repository has moved to https://github.com/ruby-jp/websocket-client-simple
|
17
|
-
|
18
|
-
=== 0.3.0 2016-02-20
|
19
|
-
|
20
|
-
* "connect" method runs a given block before connecting WebSocket #12
|
21
|
-
* thank you for suggestion @codekitchen
|
22
|
-
|
23
|
-
=== 0.2.5 2016-02-18
|
24
|
-
|
25
|
-
* bugfixed sending when broken pipe #15
|
26
|
-
* add :verify_mode option for SSL Context #14
|
27
|
-
* thank you for contributing @michaelvilensky
|
28
|
-
|
29
|
-
=== 0.2.4 2015-11-12
|
30
|
-
|
31
|
-
* support handshake headers #11
|
32
|
-
* thank you for contributing @mathieugagne
|
33
|
-
|
34
|
-
=== 0.2.3 2015-10-26
|
35
|
-
|
36
|
-
* kill thread at end of method
|
37
|
-
* thank you for contributing @hansy
|
38
|
-
|
39
|
-
=== 0.2.2 2014-11-18
|
40
|
-
|
41
|
-
* add :ssl_version option to specify version of SSL/TLS
|
42
|
-
* thank you for contributing @tonybyrne
|
43
|
-
|
44
|
-
=== 0.2.1 2014-10-19
|
45
|
-
|
46
|
-
* bugfix socket reading
|
47
|
-
|
48
|
-
=== 0.2.0 2014-06-07
|
49
|
-
|
50
|
-
* SSL support with wss:// and https:// scheme
|
51
|
-
* thank you for contributing @mallowlabs
|
52
|
-
|
53
|
-
=== 0.1.0 2014-05-08
|
54
|
-
|
55
|
-
* add accessor Client#handshake #5
|
56
|
-
* bugfix socket reading
|
57
|
-
|
58
|
-
=== 0.0.9 2014-04-03
|
59
|
-
|
60
|
-
* emit "error" in receive thread
|
61
|
-
* rescue only Errno::EPIPE, not all Errors
|
62
|
-
|
63
|
-
=== 0.0.8 2014-01-29
|
64
|
-
|
65
|
-
* bugfix Client#close #4
|
66
|
-
|
67
|
-
=== 0.0.7 2014-01-29
|
68
|
-
|
69
|
-
* send CLOSE frame in Client#close #4
|
70
|
-
|
71
|
-
=== 0.0.6 2014-01-17
|
72
|
-
|
73
|
-
* add function Client#open?
|
74
|
-
|
75
|
-
=== 0.0.5 2013-03-23
|
76
|
-
|
77
|
-
* kill read thread on close
|
78
|
-
|
79
|
-
=== 0.0.4 2013-03-23
|
80
|
-
|
81
|
-
* fix sample and README
|
82
|
-
|
83
|
-
=== 0.0.3 2013-03-23
|
84
|
-
|
85
|
-
* :type => :text option in send
|
86
|
-
|
87
|
-
=== 0.0.2 2013-03-22
|
88
|
-
|
89
|
-
* remove unnecessary sleep
|
90
|
-
|
91
|
-
=== 0.0.1 2013-03-22
|
92
|
-
|
93
|
-
* release
|