protocol-zmtp 0.1.0 → 0.1.1
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/frame.rb +15 -0
- data/lib/protocol/zmtp/connection.rb +20 -0
- 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: 041cc13ea6667319835f40ea09fae02b68cc34f988d986548691e29d48fee7ba
|
|
4
|
+
data.tar.gz: 2d396b42d33c473c0f45a0752da9ab8c292d5541464ea1cb2c667a3508297fc6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2d71dd3c5f2ad463b72c6160d8a70691a60baefe469503d59f9a2d8a80294554afaa4fdcc0a9a3ea1db19f5dcca9fda3df599ca14b6b8f9866ab90c07069294d
|
|
7
|
+
data.tar.gz: 9b5b1a1d7966fc893e08c840a2ec929eacc32f874fe5f42e8b2064fbde6be1d2b01eebfde4a4ec78ea086884ddb5363dcd5c21e0c719186a65bee475bf19d3b0
|
|
@@ -52,6 +52,21 @@ module Protocol
|
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
+
# Encodes a multi-part message into a single wire-format string.
|
|
56
|
+
# The result can be written to multiple connections without
|
|
57
|
+
# re-encoding each time (useful for fan-out patterns like PUB).
|
|
58
|
+
#
|
|
59
|
+
# @param parts [Array<String>] message frames
|
|
60
|
+
# @return [String] frozen binary wire representation
|
|
61
|
+
#
|
|
62
|
+
def self.encode_message(parts)
|
|
63
|
+
buf = +""
|
|
64
|
+
parts.each_with_index do |part, i|
|
|
65
|
+
buf << new(part, more: i < parts.size - 1).to_wire
|
|
66
|
+
end
|
|
67
|
+
buf.freeze
|
|
68
|
+
end
|
|
69
|
+
|
|
55
70
|
# Reads one frame from an IO-like object.
|
|
56
71
|
#
|
|
57
72
|
# @param io [#read_exactly] must support read_exactly(n)
|
|
@@ -91,6 +91,26 @@ module Protocol
|
|
|
91
91
|
end
|
|
92
92
|
end
|
|
93
93
|
|
|
94
|
+
# Writes pre-encoded wire bytes to the buffer without flushing.
|
|
95
|
+
# Used for fan-out: encode once, write to many connections.
|
|
96
|
+
#
|
|
97
|
+
# @param wire_bytes [String] ZMTP wire-format bytes
|
|
98
|
+
# @return [void]
|
|
99
|
+
def write_wire(wire_bytes)
|
|
100
|
+
@mutex.synchronize do
|
|
101
|
+
@io.write(wire_bytes)
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# Returns true if the ZMTP mechanism encrypts at the frame level
|
|
106
|
+
# (e.g. CURVE). TLS encryption is below ZMTP and does not affect
|
|
107
|
+
# wire-format bytes.
|
|
108
|
+
#
|
|
109
|
+
# @return [Boolean]
|
|
110
|
+
def curve?
|
|
111
|
+
@mechanism.encrypted?
|
|
112
|
+
end
|
|
113
|
+
|
|
94
114
|
# Flushes the write buffer to the underlying IO.
|
|
95
115
|
def flush
|
|
96
116
|
@mutex.synchronize do
|