tubesock 0.2.8 → 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tubesock.rb +5 -0
- data/lib/tubesock/version.rb +1 -1
- data/test/test_helper.rb +6 -2
- data/test/tubesock_test.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f0c9b5fc549d9c961037167cc3d1c4874c01b80
|
4
|
+
data.tar.gz: 8d10298543c45793683fc331e97eb7bcc8925f90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 987a397c4a369312c9b508d884df4e4aad5cc5a63b0552f9ea65649205a2c785b168b308d1544eae7558597ad45ca82a923f7046bf704221b6954ac7d0aec8cc
|
7
|
+
data.tar.gz: 78cb47bee5cdab50d1e6176283d809998b871ed8e8044efc2477ed0a64b853135f675ce8fb036ff3c715748b02d8494dfb8c5ad67e6c5594d59fcc5b10ee5530
|
data/lib/tubesock.rb
CHANGED
@@ -142,6 +142,11 @@ class Tubesock
|
|
142
142
|
return
|
143
143
|
when :text, :binary
|
144
144
|
yield frame.data
|
145
|
+
when :ping
|
146
|
+
# According to https://tools.ietf.org/html/rfc6455#section-5.5.3:
|
147
|
+
# A Pong frame sent in response to a Ping frame must have identical "Application data" as
|
148
|
+
# found in the message body of the Ping frame being replied to.'
|
149
|
+
send_data frame.data, :pong
|
145
150
|
end
|
146
151
|
end
|
147
152
|
end
|
data/lib/tubesock/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -51,11 +51,15 @@ class Tubesock::TestCase::TestInteraction
|
|
51
51
|
).to_s
|
52
52
|
end
|
53
53
|
|
54
|
-
def
|
54
|
+
def read_frame
|
55
55
|
framebuffer = WebSocket::Frame::Incoming::Client.new(version: version)
|
56
56
|
data, _addrinfo = @client_socket.recvfrom(2000)
|
57
57
|
framebuffer << data
|
58
|
-
framebuffer.next
|
58
|
+
framebuffer.next
|
59
|
+
end
|
60
|
+
|
61
|
+
def read
|
62
|
+
read_frame.data
|
59
63
|
end
|
60
64
|
|
61
65
|
def join
|
data/test/tubesock_test.rb
CHANGED
@@ -55,6 +55,20 @@ class TubesockTest < Tubesock::TestCase
|
|
55
55
|
closed.called.must_equal true
|
56
56
|
end
|
57
57
|
|
58
|
+
def test_pong_on_ping_frame
|
59
|
+
interaction = TestInteraction.new
|
60
|
+
interaction.tubesock {}
|
61
|
+
|
62
|
+
# Client ping frame from: WebSocket::Frame::Outgoing::Client.new(version: 13, data: "\x1d\xcc\x18G", type: :ping).to_s
|
63
|
+
interaction.write_raw "\x89\x84$\xBE\xDAy9r\xC2>".force_encoding('binary')
|
64
|
+
|
65
|
+
frame = interaction.read_frame
|
66
|
+
frame.data.must_equal "\x1d\xcc\x18G".force_encoding('binary')
|
67
|
+
frame.type.must_equal :pong
|
68
|
+
|
69
|
+
interaction.close
|
70
|
+
end
|
71
|
+
|
58
72
|
def test_onerror_callback
|
59
73
|
interaction = TestInteraction.new
|
60
74
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tubesock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Gauthier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|