em-websocket 0.4.0 → 0.5.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.
- data/CHANGELOG.rdoc +16 -1
- data/README.md +42 -1
- data/examples/test.html +3 -1
- data/lib/em-websocket/close03.rb +2 -0
- data/lib/em-websocket/close05.rb +2 -0
- data/lib/em-websocket/close06.rb +2 -0
- data/lib/em-websocket/close75.rb +2 -1
- data/lib/em-websocket/connection.rb +44 -19
- data/lib/em-websocket/framing03.rb +2 -1
- data/lib/em-websocket/framing05.rb +2 -1
- data/lib/em-websocket/framing07.rb +2 -1
- data/lib/em-websocket/handler.rb +8 -2
- data/lib/em-websocket/handler76.rb +2 -0
- data/lib/em-websocket/handshake.rb +5 -1
- data/lib/em-websocket/handshake04.rb +0 -5
- data/lib/em-websocket/masking04.rb +1 -5
- data/lib/em-websocket/message_processor_03.rb +5 -2
- data/lib/em-websocket/message_processor_06.rb +13 -6
- data/lib/em-websocket/version.rb +1 -1
- data/lib/em-websocket/websocket.rb +4 -0
- data/spec/helper.rb +52 -46
- data/spec/integration/common_spec.rb +11 -5
- data/spec/integration/draft03_spec.rb +82 -55
- data/spec/integration/draft05_spec.rb +13 -8
- data/spec/integration/draft06_spec.rb +65 -3
- data/spec/integration/draft13_spec.rb +31 -20
- data/spec/integration/draft75_spec.rb +32 -19
- data/spec/integration/draft76_spec.rb +62 -43
- data/spec/integration/shared_examples.rb +80 -0
- data/spec/unit/framing_spec.rb +3 -1
- data/spec/unit/masking_spec.rb +2 -0
- metadata +4 -4
@@ -29,6 +29,86 @@ shared_examples_for "a websocket server" do
|
|
29
29
|
}
|
30
30
|
end
|
31
31
|
|
32
|
+
it "should send messages successfully" do
|
33
|
+
em {
|
34
|
+
start_server { |ws|
|
35
|
+
ws.onmessage { |message|
|
36
|
+
message.should == "hello server"
|
37
|
+
done
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
start_client { |client|
|
42
|
+
client.onopen {
|
43
|
+
client.send("hello server")
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should allow connection to be closed with valid close code" do
|
50
|
+
em {
|
51
|
+
start_server { |ws|
|
52
|
+
ws.onopen {
|
53
|
+
ws.close(4004, "Bye bye")
|
54
|
+
done
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
start_client
|
59
|
+
# TODO: Use a real client which understands how to respond to closing
|
60
|
+
# handshakes, sending the handshake currently untested
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should raise error if if invalid close code is used" do
|
65
|
+
em {
|
66
|
+
start_server { |ws|
|
67
|
+
ws.onopen {
|
68
|
+
lambda {
|
69
|
+
ws.close(2000)
|
70
|
+
}.should raise_error("Application code may only use codes from 1000, 3000-4999")
|
71
|
+
done
|
72
|
+
}
|
73
|
+
}
|
74
|
+
|
75
|
+
start_client
|
76
|
+
}
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should call onclose with was_clean set to false if connection closed without closing handshake by server" do
|
80
|
+
em {
|
81
|
+
start_server { |ws|
|
82
|
+
ws.onopen {
|
83
|
+
# Close tcp connection (no close handshake)
|
84
|
+
ws.close_connection
|
85
|
+
}
|
86
|
+
ws.onclose { |event|
|
87
|
+
event.should == {:code => 1006, :was_clean => false}
|
88
|
+
done
|
89
|
+
}
|
90
|
+
}
|
91
|
+
start_client
|
92
|
+
}
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should call onclose with was_clean set to false if connection closed without closing handshake by client" do
|
96
|
+
em {
|
97
|
+
start_server { |ws|
|
98
|
+
ws.onclose { |event|
|
99
|
+
event.should == {:code => 1006, :was_clean => false}
|
100
|
+
done
|
101
|
+
}
|
102
|
+
}
|
103
|
+
start_client { |client|
|
104
|
+
client.onopen {
|
105
|
+
# Close tcp connection (no close handshake)
|
106
|
+
client.close_connection
|
107
|
+
}
|
108
|
+
}
|
109
|
+
}
|
110
|
+
end
|
111
|
+
|
32
112
|
it "should call onerror if an application error raised in onopen" do
|
33
113
|
em {
|
34
114
|
start_server { |ws|
|
data/spec/unit/framing_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: BINARY
|
2
|
+
|
1
3
|
require 'helper'
|
2
4
|
|
3
5
|
describe EM::WebSocket::Framing03 do
|
@@ -265,7 +267,7 @@ describe EM::WebSocket::Framing07 do
|
|
265
267
|
lambda {
|
266
268
|
# Opcode 3 is not supported by this draft
|
267
269
|
@f << "\x83\x05Hello"
|
268
|
-
}.should raise_error(EventMachine::WebSocket::WSProtocolError, "Unknown opcode")
|
270
|
+
}.should raise_error(EventMachine::WebSocket::WSProtocolError, "Unknown opcode 3")
|
269
271
|
end
|
270
272
|
|
271
273
|
it "should accept a fragmented unmasked text message in 3 frames" do
|
data/spec/unit/masking_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: em-websocket
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-03-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: eventmachine
|
@@ -198,7 +198,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
198
198
|
version: '0'
|
199
199
|
segments:
|
200
200
|
- 0
|
201
|
-
hash:
|
201
|
+
hash: 3271699693430314189
|
202
202
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
203
203
|
none: false
|
204
204
|
requirements:
|
@@ -207,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
207
207
|
version: '0'
|
208
208
|
segments:
|
209
209
|
- 0
|
210
|
-
hash:
|
210
|
+
hash: 3271699693430314189
|
211
211
|
requirements: []
|
212
212
|
rubyforge_project: em-websocket
|
213
213
|
rubygems_version: 1.8.24
|