protocol-websocket 0.10.0 → 0.11.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: 625dad3dc10a593cb806a3cf3174414ffab74cd1b26107e520f6c938d66713bc
4
- data.tar.gz: 6f73f9dd24b1f235310ae26afdee3cb85901d568b9414d509280cf20c38b42ff
3
+ metadata.gz: 17a6b7e17274fe574b07bc2ad242cbe383671f7f05c84fd784ec474fbde5e28a
4
+ data.tar.gz: f1098660970a0cf6069d5037dd736b52b18b7da51727c9968a96970ecd1015b0
5
5
  SHA512:
6
- metadata.gz: 128be3205862ad76b5e728de4dc9aa65dd913e903a5acdfd41267b49267f7b5c30429d8893177503ee384aed81b327b57af446dbd8ed5ac2c02b3a45111f25bf
7
- data.tar.gz: 0a7a73d4d35ce39e6b38c5d3c78af3bb1c8326605db6f7ce665cd34c6538a5941b7994f6b8c70a597fb8ae16db8c86b4f83e95189f746c2b70ffd93ec888de2b
6
+ metadata.gz: 1720e16bd8d32258b7583d9cde912229d64af57428ad3bb8644832c5b6f4e5c1588a798c9368a9638c5801f320e9b8489094d40ca5ffe45634b6d582d3f12170
7
+ data.tar.gz: 17ac4461055d2de24188f365a85e5fb80c907ab041fc62bdc2f376e24bec1178f950ef8ff4388d39c6c144e056e63d8fc8e28ab53dcd537a4f92af73c02a5dd2
checksums.yaml.gz.sig CHANGED
Binary file
@@ -55,12 +55,32 @@ module Protocol
55
55
  @framer.flush
56
56
  end
57
57
 
58
+ def open!
59
+ @state = :open
60
+
61
+ return self
62
+ end
63
+
64
+ def close!(...)
65
+ @state = :closed
66
+
67
+ return self
68
+ end
69
+
58
70
  def closed?
59
71
  @state == :closed
60
72
  end
61
73
 
62
- def close(code = Error::NO_ERROR, reason = "")
63
- send_close(code, reason) unless closed?
74
+ def close(...)
75
+ unless @state == :closed
76
+ close!
77
+
78
+ begin
79
+ send_close(...)
80
+ rescue
81
+ # Ignore.
82
+ end
83
+ end
64
84
 
65
85
  @framer.close
66
86
  end
@@ -80,11 +100,11 @@ module Protocol
80
100
 
81
101
  return frame
82
102
  rescue ProtocolError => error
83
- send_close(error.code, error.message)
103
+ close(error.code, error.message)
84
104
 
85
105
  raise
86
106
  rescue
87
- send_close(Error::PROTOCOL_ERROR, $!.message)
107
+ close(Error::PROTOCOL_ERROR, $!.message)
88
108
 
89
109
  raise
90
110
  end
@@ -120,11 +140,13 @@ module Protocol
120
140
  end
121
141
 
122
142
  def receive_close(frame)
123
- @state = :closed
124
-
125
143
  code, reason = frame.unpack
126
144
 
127
- send_close(code, reason)
145
+ # If we're already closed, then we don't need to send a close frame. Otherwise, according to the RFC, we should echo the close frame. However, it's possible it will fail to send if the connection is already closed.
146
+ unless @state == :closed
147
+ close!
148
+ send_close(code, reason)
149
+ end
128
150
 
129
151
  if code and code != Error::NO_ERROR
130
152
  raise ClosedError.new reason, code
@@ -142,18 +164,6 @@ module Protocol
142
164
  end
143
165
  end
144
166
 
145
- def open!
146
- @state = :open
147
-
148
- return self
149
- end
150
-
151
- def close!
152
- @state = :closed
153
-
154
- return self
155
- end
156
-
157
167
  def receive_ping(frame)
158
168
  if @state != :closed
159
169
  write_frame(frame.reply(mask: @mask))
@@ -198,8 +208,6 @@ module Protocol
198
208
 
199
209
  self.write_frame(frame)
200
210
  self.flush
201
-
202
- @state = :closed
203
211
  end
204
212
 
205
213
  # Write a message to the connection.
@@ -237,7 +245,7 @@ module Protocol
237
245
  end
238
246
  end
239
247
  rescue ProtocolError => error
240
- send_close(error.code, error.message)
248
+ close(error.code, error.message)
241
249
 
242
250
  raise
243
251
  end
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Protocol
7
7
  module WebSocket
8
- VERSION = "0.10.0"
8
+ VERSION = "0.11.1"
9
9
  end
10
10
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protocol-websocket
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -41,7 +41,7 @@ cert_chain:
41
41
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
42
42
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
43
43
  -----END CERTIFICATE-----
44
- date: 2023-02-04 00:00:00.000000000 Z
44
+ date: 2023-06-01 00:00:00.000000000 Z
45
45
  dependencies:
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: protocol-http
@@ -119,8 +119,6 @@ executables: []
119
119
  extensions: []
120
120
  extra_rdoc_files: []
121
121
  files:
122
- - lib/.DS_Store
123
- - lib/protocol/.DS_Store
124
122
  - lib/protocol/websocket.rb
125
123
  - lib/protocol/websocket/binary_frame.rb
126
124
  - lib/protocol/websocket/close_frame.rb
@@ -156,14 +154,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
156
154
  requirements:
157
155
  - - ">="
158
156
  - !ruby/object:Gem::Version
159
- version: 2.5.0
157
+ version: 2.7.6
160
158
  required_rubygems_version: !ruby/object:Gem::Requirement
161
159
  requirements:
162
160
  - - ">="
163
161
  - !ruby/object:Gem::Version
164
162
  version: '0'
165
163
  requirements: []
166
- rubygems_version: 3.4.1
164
+ rubygems_version: 3.4.7
167
165
  signing_key:
168
166
  specification_version: 4
169
167
  summary: A low level implementation of the WebSocket protocol.
metadata.gz.sig CHANGED
Binary file
data/lib/.DS_Store DELETED
Binary file
Binary file