protocol-websocket 0.16.0 → 0.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/protocol/websocket/close_frame.rb +8 -0
- data/lib/protocol/websocket/connection.rb +22 -1
- data/lib/protocol/websocket/error.rb +16 -2
- data/lib/protocol/websocket/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c565e42a63322140910616237842446c9faf392325569500454cff2bcfe500d
|
4
|
+
data.tar.gz: db2129c90eb70609ef3b14f62c5a8f261cca9d4e5796be21c15ed24f545f3a19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68c058f51adbcadb882cfd139bc88a0dbdb0d1024d3c7cc62794796e83ab730340b72289f505f5fcd1d213cda0901f4b16aaee42c899c25ffca57e3baa057078
|
7
|
+
data.tar.gz: 80121ca724e4f275a88479d4778aa35070b0ddc62660ad4acda47247a1ed7461137a5227e65ea8c3569120a0bf98ff0c0a24b33039d4cf67602b825c2289891a
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -59,6 +59,14 @@ module Protocol
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
+
# Generate a suitable reply.
|
63
|
+
# @returns [CloseFrame]
|
64
|
+
def reply(code = Error::NO_ERROR, reason = "")
|
65
|
+
frame = CloseFrame.new
|
66
|
+
frame.pack(code, reason)
|
67
|
+
return frame
|
68
|
+
end
|
69
|
+
|
62
70
|
# Apply this frame to the specified connection.
|
63
71
|
def apply(connection)
|
64
72
|
connection.receive_close(self)
|
@@ -89,13 +89,34 @@ module Protocol
|
|
89
89
|
@state == :closed
|
90
90
|
end
|
91
91
|
|
92
|
-
# Immediately transition the connection to the closed state *and* close the underlying connection.
|
92
|
+
# Immediately transition the connection to the closed state *and* close the underlying connection. Any data not yet read will be lost.
|
93
93
|
def close(...)
|
94
94
|
close!(...)
|
95
95
|
|
96
96
|
@framer.close
|
97
97
|
end
|
98
98
|
|
99
|
+
# Close the connection gracefully, sending a close frame with the specified error code and reason. If an error occurs while sending the close frame, the connection will be closed immediately. You may continue to read data from the connection after calling this method, but you should not write any more data.
|
100
|
+
#
|
101
|
+
# @parameter error [Error | Nil] The error that occurred, if any.
|
102
|
+
def close_write(error = nil)
|
103
|
+
if error
|
104
|
+
send_close(Error::INTERNAL_ERROR, error.message)
|
105
|
+
else
|
106
|
+
send_close
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
# Close the connection gracefully. This will send a close frame and wait for the remote end to respond with a close frame. Any data received after the close frame is sent will be ignored. If you want to process this data, use {#close_write} instead, and read the data before calling {#close}.
|
111
|
+
def shutdown
|
112
|
+
send_close unless @state == :closed
|
113
|
+
|
114
|
+
# `read_frame` will return nil after receiving a close frame:
|
115
|
+
while read_frame
|
116
|
+
# Drain the connection.
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
99
120
|
# Read a frame from the framer, and apply it to the connection.
|
100
121
|
def read_frame
|
101
122
|
return nil if closed?
|
@@ -19,10 +19,24 @@ module Protocol
|
|
19
19
|
# Indicates that an endpoint is terminating the connection due to a protocol error.
|
20
20
|
PROTOCOL_ERROR = 1002
|
21
21
|
|
22
|
-
# Indicates that an endpoint is terminating the connection because it has received a type of data it cannot accept.
|
22
|
+
# Indicates that an endpoint is terminating the connection because it has received a type of data it cannot accept. (e.g., an endpoint that understands only text data MAY send this if it receives a binary message).
|
23
23
|
INVALID_DATA = 1003
|
24
24
|
|
25
|
-
|
25
|
+
|
26
|
+
# Indicates that an endpoint is terminating the connection because it has received data within a message that was not consistent with the type of the message (e.g., non-UTF-8 data within a text message).
|
27
|
+
INVALID_PAYLOAD = 1007
|
28
|
+
|
29
|
+
# Indicates that an endpoint is terminating the connection because it has received a message that violates its policy. This is a generic status code that can be returned when there is no other more suitable status code (e.g., 1003 or 1009) or if there is a need to hide specific details about the policy.
|
30
|
+
POLICY_VIOLATION = 1008
|
31
|
+
|
32
|
+
# Indicates that an endpoint is terminating the connection because it has received a message that is too big for it to process.
|
33
|
+
MESSAGE_TOO_LARGE = 1009
|
34
|
+
|
35
|
+
# Indicates that an endpoint (client) is terminating the connection because it has expected the server to negotiate one or more extension, but the server didn't return them in the response message of the WebSocket handshake. The list of extensions that are needed should appear in the /reason/ part of the Close frame. Note that this status code is not used by the server, because it can fail the WebSocket handshake instead.
|
36
|
+
MISSING_EXTENSION = 1010
|
37
|
+
|
38
|
+
# Indicates that a server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request.
|
39
|
+
INTERNAL_ERROR = 1011
|
26
40
|
end
|
27
41
|
|
28
42
|
# Raised by stream or connection handlers, results in GOAWAY frame which signals termination of the current connection. You *cannot* recover from this exception, or any exceptions subclassed from it.
|
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.
|
4
|
+
version: 0.17.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: 2024-09-
|
44
|
+
date: 2024-09-11 00:00:00.000000000 Z
|
45
45
|
dependencies:
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: protocol-http
|
metadata.gz.sig
CHANGED
Binary file
|