protocol-websocket 0.10.0 → 0.11.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: 625dad3dc10a593cb806a3cf3174414ffab74cd1b26107e520f6c938d66713bc
4
- data.tar.gz: 6f73f9dd24b1f235310ae26afdee3cb85901d568b9414d509280cf20c38b42ff
3
+ metadata.gz: 58b07db9f128f30d49b779a04a08624afbeb59abe9cc3e0028ded1e2d5e6a7f3
4
+ data.tar.gz: 646c2a5004051f46d6f4872fec0842d695d6e4a1b2273421bc164293315df4e0
5
5
  SHA512:
6
- metadata.gz: 128be3205862ad76b5e728de4dc9aa65dd913e903a5acdfd41267b49267f7b5c30429d8893177503ee384aed81b327b57af446dbd8ed5ac2c02b3a45111f25bf
7
- data.tar.gz: 0a7a73d4d35ce39e6b38c5d3c78af3bb1c8326605db6f7ce665cd34c6538a5941b7994f6b8c70a597fb8ae16db8c86b4f83e95189f746c2b70ffd93ec888de2b
6
+ metadata.gz: f1f28c28daa4dc109df788ae226c4b9a0a1081d20a2316a4e23ff48e1632dd9662a32c2bad2573fed32cde1624c7ab7c23a53b805e946068a70543f93b188cbf
7
+ data.tar.gz: 0d64b3c9f3d809bd6b965b15780be053c15cfc37ff7fc5c66d0d7dc73e614821550ee25746f6a4b28b9c6f69603254daa3f4bd83b63e4cd5dbe8b4f223be9ab6
checksums.yaml.gz.sig CHANGED
@@ -1,3 +1,3 @@
1
- ��7c4W����;��F��!_����U���?���>���/�G�EF3�|�Q��G�y�eyIj1��lx2@s���ch��ä��n Pk�j��'�~������0�ϣ� ����9D]Ǐ:�*}�� s 2�=� kx���*��Wo�� 4�����H/[PU�������e#^od)����A���#HϢ��RvK�'Y�Aީ)�[���_M��}��2���̒jҋ��d� ���d�/9�
2
- `�Z>�'Q� ��G)r6��@.�Q%?>���HN�? �����U|n�*Fڊ�O�8�%6)�n�ʉ|�j����h����G�V0$�V��"(�$]��D �u�!�1��
3
- 3C����U���7�
1
+ l��ҭ ��V4�$C==N�*$���De�Z8j�k��.�a<!���Ih�Z��84����m@�"sk�58Gؒ�
2
+ =~�{�!�ַuWY����M�F�
3
+ ����nG~�b�o�4#�3��響`�K���Y�����9.�λ��J��b�虎�;r1�5�����y,0�J��od���I���� y���X�\V +��|R-g�7��Et����n����c���q��n�5�8u{'��6wY1�v��L���Vڤ�l��!ߤ���$��Ի�.b�$����b'bٳ��'HbJ^�!���Q��Yeb���j�܍=F�-8�!VT��o����*��$���g�d�&�O��-I|HB
@@ -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.0"
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.0
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-03-07 00:00:00.000000000 Z
45
45
  dependencies:
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: protocol-http
@@ -163,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
163
  - !ruby/object:Gem::Version
164
164
  version: '0'
165
165
  requirements: []
166
- rubygems_version: 3.4.1
166
+ rubygems_version: 3.4.6
167
167
  signing_key:
168
168
  specification_version: 4
169
169
  summary: A low level implementation of the WebSocket protocol.
metadata.gz.sig CHANGED
Binary file