protocol-websocket 0.9.0 → 0.9.1
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 +3 -3
- data/lib/protocol/websocket/connection.rb +1 -0
- data/lib/protocol/websocket/json_message.rb +47 -0
- data/lib/protocol/websocket/message.rb +2 -1
- data/lib/protocol/websocket/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +2 -1
- 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: 0ca30621d2f489b08f475047f539d2fe048661dbe2b109a8d0ef441c6e95ed37
|
4
|
+
data.tar.gz: fe325e6b9041103c704cf912f73f3838c2e9d50af6368b2db54e280906600aa4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35a0841efafc3a3b1fb98cbfdccff848a51262cf3e493d78cb95c4f300a1ced40779837d51e31edfd5d2cc3626b4ad22fd9f1066bcedfd4b9d8d460d44e9ddf4
|
7
|
+
data.tar.gz: 1528871ed4e31683e9334eb91096d7ad6cf592d60020bd151e70e93324d727067dfc2a62c8ec8471ba3f3f56e289cc95890f7a6d89e32afce62c2a5fd55506fc
|
checksums.yaml.gz.sig
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
[�uy�jZ�L!=�5C���14���r��{���i���ij��1��I��|�żKU��(���][�H����q\��yB�C�3J�3�*���Lf�rEc��oa�$qVY;PWcG^M'^*c��(�4�Fy�����G��q1�o��Ǵ��Z���i�b��S
|
2
|
+
�&{�\S�s^C��1�<S�GRbxD�
|
3
|
+
3OEI}��"�ͿՓ�}w�Ɖ0�s#�-f��Q�Y���$~ʲa����/I��˩&s���t���&��E�,#�kzD�*<�
|
@@ -212,6 +212,7 @@ module Protocol
|
|
212
212
|
# Write a message to the connection.
|
213
213
|
# @parameter message [Message] The message to send.
|
214
214
|
def write(message, **options)
|
215
|
+
# This is a compatibility shim for the previous implementation. We may want to eventually deprecate this use case... or maybe it's convenient enough to leave it around.
|
215
216
|
if message.is_a?(String)
|
216
217
|
if message.encoding == Encoding::UTF_8
|
217
218
|
return send_text(message, **options)
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# Copyright, 2022, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
21
|
+
require 'json'
|
22
|
+
|
23
|
+
require_relative 'message'
|
24
|
+
|
25
|
+
module Protocol
|
26
|
+
module WebSocket
|
27
|
+
class JSONMessage < TextMessage
|
28
|
+
def self.wrap(message)
|
29
|
+
if message.is_a?(TextMessage)
|
30
|
+
self.new(message.buffer)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.generate(object)
|
35
|
+
self.new(JSON.generate(object))
|
36
|
+
end
|
37
|
+
|
38
|
+
def parse(symbolize_names: true, **options)
|
39
|
+
JSON.parse(@buffer, symbolize_names: symbolize_names, **options)
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_h
|
43
|
+
parse.to_h
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
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.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -136,6 +136,7 @@ files:
|
|
136
136
|
- lib/protocol/websocket/frame.rb
|
137
137
|
- lib/protocol/websocket/framer.rb
|
138
138
|
- lib/protocol/websocket/headers.rb
|
139
|
+
- lib/protocol/websocket/json_message.rb
|
139
140
|
- lib/protocol/websocket/message.rb
|
140
141
|
- lib/protocol/websocket/ping_frame.rb
|
141
142
|
- lib/protocol/websocket/pong_frame.rb
|
metadata.gz.sig
CHANGED
Binary file
|