protocol-zmtp 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/protocol/zmtp/codec/command.rb +2 -2
- data/lib/protocol/zmtp/codec/frame.rb +6 -4
- data/lib/protocol/zmtp/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fe0884f347da68db2bbd04949c944108a997d67f545e511e5a74973a84c1d359
|
|
4
|
+
data.tar.gz: ff1542dd2feffb84db290fc1dacb8e06d10da80282619c342a59d8d239388125
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 41b15de98c2e4f0ed6db44f9cf9d9524e4dac42c1f01bf75652a363c9afbedc1af755b7531e113e32abea1a3fd64f164446190c81e036a172989868b5bd712a0
|
|
7
|
+
data.tar.gz: 7325e3b59a72b14776128de68361f0507ebfca31d52646aadd1688b6b022e8b04fa9308c3b8a2da7ddccccaaa1d5ed81d58f9f8a0f15a308fd0e196f8b45ceb9
|
|
@@ -20,14 +20,14 @@ module Protocol
|
|
|
20
20
|
# @return [String] command name (e.g. "READY", "SUBSCRIBE")
|
|
21
21
|
attr_reader :name
|
|
22
22
|
|
|
23
|
+
|
|
23
24
|
# @return [String] command data (binary)
|
|
24
25
|
attr_reader :data
|
|
25
26
|
|
|
26
|
-
EMPTY_DATA = "".b.freeze
|
|
27
27
|
|
|
28
28
|
# @param name [String] command name
|
|
29
29
|
# @param data [String] command data
|
|
30
|
-
def initialize(name, data =
|
|
30
|
+
def initialize(name, data = EMPTY_BINARY)
|
|
31
31
|
@name = name
|
|
32
32
|
@data = data.encoding == Encoding::BINARY ? data : data.b
|
|
33
33
|
end
|
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
module Protocol
|
|
4
4
|
module ZMTP
|
|
5
5
|
module Codec
|
|
6
|
+
|
|
7
|
+
# Frozen empty binary string for zero-length frame bodies.
|
|
8
|
+
EMPTY_BINARY = "".b.freeze
|
|
9
|
+
|
|
10
|
+
|
|
6
11
|
# ZMTP frame encode/decode.
|
|
7
12
|
#
|
|
8
13
|
# Wire format:
|
|
@@ -22,9 +27,6 @@ module Protocol
|
|
|
22
27
|
# Pre-computed single-byte flag strings (avoids Integer#chr + String#b per frame).
|
|
23
28
|
FLAG_BYTES = Array.new(256) { |i| i.chr.b.freeze }.freeze
|
|
24
29
|
|
|
25
|
-
# Frozen empty binary string for zero-length frame bodies.
|
|
26
|
-
EMPTY_BODY = "".b.freeze
|
|
27
|
-
|
|
28
30
|
|
|
29
31
|
# @return [String] frame body (binary)
|
|
30
32
|
attr_reader :body
|
|
@@ -112,7 +114,7 @@ module Protocol
|
|
|
112
114
|
raise Error, "frame size #{size} exceeds max_message_size #{max_message_size}"
|
|
113
115
|
end
|
|
114
116
|
|
|
115
|
-
body = size > 0 ? io.read_exactly(size) :
|
|
117
|
+
body = size > 0 ? io.read_exactly(size) : EMPTY_BINARY
|
|
116
118
|
|
|
117
119
|
new(body, more: more, command: command)
|
|
118
120
|
end
|