faye 0.8.8 → 0.8.9
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of faye might be problematic. Click here for more details.
- data/History.txt +16 -10
- data/README.rdoc +1 -1
- data/lib/faye-browser-min.js +1 -1
- data/lib/faye-browser-min.js.map +2 -2
- data/lib/faye-browser.js +302 -287
- data/lib/faye.rb +21 -21
- data/lib/faye/adapters/rack_adapter.rb +50 -48
- data/lib/faye/adapters/static_server.rb +22 -22
- data/lib/faye/engines/connection.rb +13 -13
- data/lib/faye/engines/memory.rb +21 -21
- data/lib/faye/engines/proxy.rb +23 -23
- data/lib/faye/error.rb +6 -6
- data/lib/faye/mixins/logging.rb +12 -12
- data/lib/faye/mixins/publisher.rb +6 -6
- data/lib/faye/mixins/timeouts.rb +1 -1
- data/lib/faye/protocol/channel.rb +24 -24
- data/lib/faye/protocol/client.rb +71 -73
- data/lib/faye/protocol/extensible.rb +7 -7
- data/lib/faye/protocol/grammar.rb +13 -13
- data/lib/faye/protocol/server.rb +57 -57
- data/lib/faye/protocol/socket.rb +4 -4
- data/lib/faye/protocol/subscription.rb +4 -4
- data/lib/faye/transport/http.rb +13 -13
- data/lib/faye/transport/local.rb +5 -5
- data/lib/faye/transport/transport.rb +25 -25
- data/lib/faye/transport/web_socket.rb +34 -30
- data/lib/faye/util/namespace.rb +4 -4
- data/spec/browser.html +5 -5
- data/spec/javascript/channel_spec.js +3 -3
- data/spec/javascript/client_spec.js +104 -98
- data/spec/javascript/engine/memory_spec.js +1 -1
- data/spec/javascript/engine_spec.js +70 -70
- data/spec/javascript/faye_spec.js +6 -6
- data/spec/javascript/grammar_spec.js +12 -12
- data/spec/javascript/node_adapter_spec.js +46 -46
- data/spec/javascript/publisher_spec.js +4 -4
- data/spec/javascript/server/connect_spec.js +21 -21
- data/spec/javascript/server/disconnect_spec.js +15 -15
- data/spec/javascript/server/extensions_spec.js +6 -6
- data/spec/javascript/server/handshake_spec.js +18 -18
- data/spec/javascript/server/integration_spec.js +23 -23
- data/spec/javascript/server/publish_spec.js +9 -9
- data/spec/javascript/server/subscribe_spec.js +30 -30
- data/spec/javascript/server/unsubscribe_spec.js +30 -30
- data/spec/javascript/server_spec.js +15 -15
- data/spec/javascript/transport_spec.js +32 -27
- data/spec/node.js +2 -2
- data/spec/ruby/channel_spec.rb +2 -2
- data/spec/ruby/client_spec.rb +100 -92
- data/spec/ruby/engine_examples.rb +51 -51
- data/spec/ruby/faye_spec.rb +5 -5
- data/spec/ruby/grammar_spec.rb +12 -12
- data/spec/ruby/publisher_spec.rb +4 -4
- data/spec/ruby/rack_adapter_spec.rb +34 -34
- data/spec/ruby/server/connect_spec.rb +22 -22
- data/spec/ruby/server/disconnect_spec.rb +16 -16
- data/spec/ruby/server/extensions_spec.rb +8 -8
- data/spec/ruby/server/handshake_spec.rb +20 -20
- data/spec/ruby/server/integration_spec.rb +22 -24
- data/spec/ruby/server/publish_spec.rb +9 -9
- data/spec/ruby/server/subscribe_spec.rb +31 -31
- data/spec/ruby/server/unsubscribe_spec.rb +31 -31
- data/spec/ruby/server_spec.rb +17 -17
- data/spec/ruby/transport_spec.rb +23 -23
- data/spec/testswarm +23 -10
- data/spec/thin_proxy.rb +5 -5
- metadata +90 -59
@@ -4,7 +4,7 @@ JS.ENV.Server.ConnectSpec = JS.Test.describe("Server connect", function() { with
|
|
4
4
|
stub(Faye.Engine, "get").returns(engine)
|
5
5
|
this.server = new Faye.Server()
|
6
6
|
}})
|
7
|
-
|
7
|
+
|
8
8
|
describe("#connect", function() { with(this) {
|
9
9
|
before(function() { with(this) {
|
10
10
|
this.clientId = "fakeclientid"
|
@@ -12,18 +12,18 @@ JS.ENV.Server.ConnectSpec = JS.Test.describe("Server connect", function() { with
|
|
12
12
|
clientId: "fakeclientid",
|
13
13
|
connectionType: "long-polling"}
|
14
14
|
}})
|
15
|
-
|
15
|
+
|
16
16
|
describe("with valid parameters", function() { with(this) {
|
17
17
|
before(function() { with(this) {
|
18
18
|
message.advice = {timeout: 60}
|
19
19
|
expect(engine, "clientExists").given(clientId).yielding([true])
|
20
20
|
}})
|
21
|
-
|
21
|
+
|
22
22
|
it("connects to the engine to wait for new messages", function() { with(this) {
|
23
23
|
expect(engine, "connect").given(clientId, {timeout: 60}).yielding([[]])
|
24
24
|
server.connect(message, false, function() {})
|
25
25
|
}})
|
26
|
-
|
26
|
+
|
27
27
|
it("returns a successful response and any queued messages", function() { with(this) {
|
28
28
|
stub(engine, "connect").yields([{channel: "/x", data: "hello"}])
|
29
29
|
server.connect(message, false, function(response) {
|
@@ -38,10 +38,10 @@ JS.ENV.Server.ConnectSpec = JS.Test.describe("Server connect", function() { with
|
|
38
38
|
], response)
|
39
39
|
})
|
40
40
|
}})
|
41
|
-
|
41
|
+
|
42
42
|
describe("with a message id", function() { with(this) {
|
43
43
|
before(function() { this.message.id = "foo" })
|
44
|
-
|
44
|
+
|
45
45
|
it("returns the same id", function() { with(this) {
|
46
46
|
stub(engine, "connect")
|
47
47
|
server.connect(message, false, function(response) {
|
@@ -55,17 +55,17 @@ JS.ENV.Server.ConnectSpec = JS.Test.describe("Server connect", function() { with
|
|
55
55
|
}})
|
56
56
|
}})
|
57
57
|
}})
|
58
|
-
|
58
|
+
|
59
59
|
describe("with an unknown client", function() { with(this) {
|
60
60
|
before(function() { with(this) {
|
61
61
|
expect(engine, "clientExists").given(clientId).yielding([false])
|
62
62
|
}})
|
63
|
-
|
63
|
+
|
64
64
|
it("does not connect to the engine", function() { with(this) {
|
65
65
|
expect(engine, "connect").exactly(0)
|
66
66
|
server.connect(message, false, function() {})
|
67
67
|
}})
|
68
|
-
|
68
|
+
|
69
69
|
it("returns an unsuccessful response", function() { with(this) {
|
70
70
|
server.connect(message, false, function(response) {
|
71
71
|
assertEqual({
|
@@ -76,18 +76,18 @@ JS.ENV.Server.ConnectSpec = JS.Test.describe("Server connect", function() { with
|
|
76
76
|
})
|
77
77
|
}})
|
78
78
|
}})
|
79
|
-
|
79
|
+
|
80
80
|
describe("missing clientId", function() { with(this) {
|
81
81
|
before(function() { with(this) {
|
82
82
|
delete message.clientId
|
83
83
|
expect(engine, "clientExists").given(undefined).yielding([false])
|
84
84
|
}})
|
85
|
-
|
85
|
+
|
86
86
|
it("does not connect to the engine", function() { with(this) {
|
87
87
|
expect(engine, "connect").exactly(0)
|
88
88
|
server.connect(message, false, function() {})
|
89
89
|
}})
|
90
|
-
|
90
|
+
|
91
91
|
it("returns an unsuccessful response", function() { with(this) {
|
92
92
|
server.connect(message, false, function(response) {
|
93
93
|
assertEqual({
|
@@ -98,18 +98,18 @@ JS.ENV.Server.ConnectSpec = JS.Test.describe("Server connect", function() { with
|
|
98
98
|
})
|
99
99
|
}})
|
100
100
|
}})
|
101
|
-
|
101
|
+
|
102
102
|
describe("missing connectionType", function() { with(this) {
|
103
103
|
before(function() { with(this) {
|
104
104
|
delete message.connectionType
|
105
105
|
expect(engine, "clientExists").given(clientId).yielding([true])
|
106
106
|
}})
|
107
|
-
|
107
|
+
|
108
108
|
it("does not connect to the engine", function() { with(this) {
|
109
109
|
expect(engine, "connect").exactly(0)
|
110
110
|
server.connect(message, false, function() {})
|
111
111
|
}})
|
112
|
-
|
112
|
+
|
113
113
|
it("returns an unsuccessful response", function() { with(this) {
|
114
114
|
server.connect(message, false, function(response) {
|
115
115
|
assertEqual({
|
@@ -120,18 +120,18 @@ JS.ENV.Server.ConnectSpec = JS.Test.describe("Server connect", function() { with
|
|
120
120
|
})
|
121
121
|
}})
|
122
122
|
}})
|
123
|
-
|
123
|
+
|
124
124
|
describe("with an unknown connectionType", function() { with(this) {
|
125
125
|
before(function() { with(this) {
|
126
126
|
message.connectionType = "flash"
|
127
127
|
expect(engine, "clientExists").given(clientId).yielding([true])
|
128
128
|
}})
|
129
|
-
|
129
|
+
|
130
130
|
it("does not connect to the engine", function() { with(this) {
|
131
131
|
expect(engine, "connect").exactly(0)
|
132
132
|
server.connect(message, false, function() {})
|
133
133
|
}})
|
134
|
-
|
134
|
+
|
135
135
|
it("returns an unsuccessful response", function() { with(this) {
|
136
136
|
server.connect(message, false, function(response) {
|
137
137
|
assertEqual({
|
@@ -142,18 +142,18 @@ JS.ENV.Server.ConnectSpec = JS.Test.describe("Server connect", function() { with
|
|
142
142
|
})
|
143
143
|
}})
|
144
144
|
}})
|
145
|
-
|
145
|
+
|
146
146
|
describe("with an error", function() { with(this) {
|
147
147
|
before(function() { with(this) {
|
148
148
|
message.error = "invalid"
|
149
149
|
expect(engine, "clientExists").given(clientId).yielding([true])
|
150
150
|
}})
|
151
|
-
|
151
|
+
|
152
152
|
it("does not connect to the engine", function() { with(this) {
|
153
153
|
expect(engine, "connect").exactly(0)
|
154
154
|
server.connect(message, false, function() {})
|
155
155
|
}})
|
156
|
-
|
156
|
+
|
157
157
|
it("returns an unsuccessful response", function() { with(this) {
|
158
158
|
server.connect(message, false, function(response) {
|
159
159
|
assertEqual({
|
@@ -4,24 +4,24 @@ JS.ENV.Server.DisconnectSpec = JS.Test.describe("Server disconnect", function()
|
|
4
4
|
stub(Faye.Engine, "get").returns(engine)
|
5
5
|
this.server = new Faye.Server()
|
6
6
|
}})
|
7
|
-
|
7
|
+
|
8
8
|
describe("#disconnect", function() { with(this) {
|
9
9
|
before(function() { with(this) {
|
10
10
|
this.clientId = "fakeclientid"
|
11
11
|
this.message = {channel: "/meta/disconnect",
|
12
12
|
clientId: "fakeclientid"}
|
13
13
|
}})
|
14
|
-
|
14
|
+
|
15
15
|
describe("with valid parameters", function() { with(this) {
|
16
16
|
before(function() { with(this) {
|
17
17
|
expect(engine, "clientExists").given(clientId).yielding([true])
|
18
18
|
}})
|
19
|
-
|
19
|
+
|
20
20
|
it("destroys the client", function() { with(this) {
|
21
21
|
expect(engine, "destroyClient").given(clientId)
|
22
22
|
server.disconnect(message, false, function() {})
|
23
23
|
}})
|
24
|
-
|
24
|
+
|
25
25
|
it("returns a successful response", function() { with(this) {
|
26
26
|
stub(engine, "destroyClient")
|
27
27
|
server.disconnect(message, false, function(response) {
|
@@ -32,10 +32,10 @@ JS.ENV.Server.DisconnectSpec = JS.Test.describe("Server disconnect", function()
|
|
32
32
|
}, response)
|
33
33
|
})
|
34
34
|
}})
|
35
|
-
|
35
|
+
|
36
36
|
describe("with a message id", function() { with(this) {
|
37
37
|
before(function() { this.message.id = "foo" })
|
38
|
-
|
38
|
+
|
39
39
|
it("returns the same id", function() { with(this) {
|
40
40
|
stub(engine, "destroyClient")
|
41
41
|
server.disconnect(message, false, function(response) {
|
@@ -49,17 +49,17 @@ JS.ENV.Server.DisconnectSpec = JS.Test.describe("Server disconnect", function()
|
|
49
49
|
}})
|
50
50
|
}})
|
51
51
|
}})
|
52
|
-
|
52
|
+
|
53
53
|
describe("with an unknown client", function() { with(this) {
|
54
54
|
before(function() { with(this) {
|
55
55
|
expect(engine, "clientExists").given(clientId).yielding([false])
|
56
56
|
}})
|
57
|
-
|
57
|
+
|
58
58
|
it("does not destroy the client", function() { with(this) {
|
59
59
|
expect(engine, "destroyClient").exactly(0)
|
60
60
|
server.disconnect(message, false, function() {})
|
61
61
|
}})
|
62
|
-
|
62
|
+
|
63
63
|
it("returns an unsuccessful response", function() { with(this) {
|
64
64
|
stub(engine, "destroyClient")
|
65
65
|
server.disconnect(message, false, function(response) {
|
@@ -71,18 +71,18 @@ JS.ENV.Server.DisconnectSpec = JS.Test.describe("Server disconnect", function()
|
|
71
71
|
})
|
72
72
|
}})
|
73
73
|
}})
|
74
|
-
|
74
|
+
|
75
75
|
describe("missing clientId", function() { with(this) {
|
76
76
|
before(function() { with(this) {
|
77
77
|
delete message.clientId
|
78
78
|
expect(engine, "clientExists").given(undefined).yielding([false])
|
79
79
|
}})
|
80
|
-
|
80
|
+
|
81
81
|
it("does not destroy the client", function() { with(this) {
|
82
82
|
expect(engine, "destroyClient").exactly(0)
|
83
83
|
server.disconnect(message, false, function() {})
|
84
84
|
}})
|
85
|
-
|
85
|
+
|
86
86
|
it("returns an unsuccessful response", function() { with(this) {
|
87
87
|
stub(engine, "destroyClient")
|
88
88
|
server.disconnect(message, false, function(response) {
|
@@ -94,18 +94,18 @@ JS.ENV.Server.DisconnectSpec = JS.Test.describe("Server disconnect", function()
|
|
94
94
|
})
|
95
95
|
}})
|
96
96
|
}})
|
97
|
-
|
97
|
+
|
98
98
|
describe("with an error", function() { with(this) {
|
99
99
|
before(function() { with(this) {
|
100
100
|
message.error = "invalid"
|
101
101
|
expect(engine, "clientExists").given(clientId).yielding([true])
|
102
102
|
}})
|
103
|
-
|
103
|
+
|
104
104
|
it("does not destroy the client", function() { with(this) {
|
105
105
|
expect(engine, "destroyClient").exactly(0)
|
106
106
|
server.disconnect(message, false, function() {})
|
107
107
|
}})
|
108
|
-
|
108
|
+
|
109
109
|
it("returns an unsuccessful response", function() { with(this) {
|
110
110
|
stub(engine, "destroyClient")
|
111
111
|
server.disconnect(message, false, function(response) {
|
@@ -4,7 +4,7 @@ JS.ENV.Server.ExtensionsSpec = JS.Test.describe("Server extensions", function()
|
|
4
4
|
stub(Faye.Engine, "get").returns(engine)
|
5
5
|
this.server = new Faye.Server()
|
6
6
|
}})
|
7
|
-
|
7
|
+
|
8
8
|
describe("with an incoming extension installed", function() { with(this) {
|
9
9
|
before(function() { with(this) {
|
10
10
|
var extension = {
|
@@ -16,12 +16,12 @@ JS.ENV.Server.ExtensionsSpec = JS.Test.describe("Server extensions", function()
|
|
16
16
|
server.addExtension(extension)
|
17
17
|
this.message = {channel: "/foo", data: "hello"}
|
18
18
|
}})
|
19
|
-
|
19
|
+
|
20
20
|
it("passes incoming messages through the extension", function() { with(this) {
|
21
21
|
expect(engine, "publish").given({channel: "/foo", data: "hello", ext: {auth: "password"}})
|
22
22
|
server.process(message, false, function() {})
|
23
23
|
}})
|
24
|
-
|
24
|
+
|
25
25
|
it("does not pass outgoing messages through the extension", function() { with(this) {
|
26
26
|
stub(server, "handshake").yields([message])
|
27
27
|
stub(engine, "publish")
|
@@ -30,7 +30,7 @@ JS.ENV.Server.ExtensionsSpec = JS.Test.describe("Server extensions", function()
|
|
30
30
|
assertEqual( [{channel: "/foo", data: "hello"}], response )
|
31
31
|
}})
|
32
32
|
}})
|
33
|
-
|
33
|
+
|
34
34
|
describe("with an outgoing extension installed", function() { with(this) {
|
35
35
|
before(function() { with(this) {
|
36
36
|
var extension = {
|
@@ -42,12 +42,12 @@ JS.ENV.Server.ExtensionsSpec = JS.Test.describe("Server extensions", function()
|
|
42
42
|
server.addExtension(extension)
|
43
43
|
this.message = {channel: "/foo", data: "hello"}
|
44
44
|
}})
|
45
|
-
|
45
|
+
|
46
46
|
it("does not pass incoming messages through the extension", function() { with(this) {
|
47
47
|
expect(engine, "publish").given({channel: "/foo", data: "hello"})
|
48
48
|
server.process(message, false, function() {})
|
49
49
|
}})
|
50
|
-
|
50
|
+
|
51
51
|
it("passes outgoing messages through the extension", function() { with(this) {
|
52
52
|
stub(server, "handshake").yields([message])
|
53
53
|
stub(engine, "publish")
|
@@ -3,25 +3,25 @@ JS.ENV.Server.HandshakeSpec = JS.Test.describe("Server handshake", function() {
|
|
3
3
|
this.engine = {}
|
4
4
|
stub(Faye.Engine, "get").returns(engine)
|
5
5
|
this.server = new Faye.Server()
|
6
|
-
|
6
|
+
|
7
7
|
this.connectionTypes = ["long-polling", "cross-origin-long-polling",
|
8
8
|
"callback-polling","websocket",
|
9
9
|
"eventsource","in-process"]
|
10
10
|
}})
|
11
|
-
|
11
|
+
|
12
12
|
describe("#handshake", function() { with(this) {
|
13
13
|
before(function() { with(this) {
|
14
14
|
this.message = {channel: "/meta/handshake",
|
15
15
|
version: "1.0",
|
16
16
|
supportedConnectionTypes: ["long-polling"]}
|
17
17
|
}})
|
18
|
-
|
18
|
+
|
19
19
|
describe("with valid parameters", function() { with(this) {
|
20
20
|
it("creates a client", function() { with(this) {
|
21
21
|
expect(engine, "createClient")
|
22
22
|
server.handshake(message, false, function() {})
|
23
23
|
}})
|
24
|
-
|
24
|
+
|
25
25
|
it("returns a successful response", function() { with(this) {
|
26
26
|
stub(engine, "createClient").yields(["clientid"])
|
27
27
|
server.handshake(message, false, function(response) {
|
@@ -34,10 +34,10 @@ JS.ENV.Server.HandshakeSpec = JS.Test.describe("Server handshake", function() {
|
|
34
34
|
}, response)
|
35
35
|
})
|
36
36
|
}})
|
37
|
-
|
37
|
+
|
38
38
|
describe("with a message id", function() { with(this) {
|
39
39
|
before(function() { this.message.id = "foo" })
|
40
|
-
|
40
|
+
|
41
41
|
it("returns the same id", function() { with(this) {
|
42
42
|
stub(engine, "createClient").yields(["clientid"])
|
43
43
|
server.handshake(message, false, function(response) {
|
@@ -53,15 +53,15 @@ JS.ENV.Server.HandshakeSpec = JS.Test.describe("Server handshake", function() {
|
|
53
53
|
}})
|
54
54
|
}})
|
55
55
|
}})
|
56
|
-
|
56
|
+
|
57
57
|
describe("missing version", function() { with(this) {
|
58
58
|
before(function() { delete this.message.version })
|
59
|
-
|
59
|
+
|
60
60
|
it("does not create a client", function() { with(this) {
|
61
61
|
expect(engine, "createClient").exactly(0)
|
62
62
|
server.handshake(message, false, function() {})
|
63
63
|
}})
|
64
|
-
|
64
|
+
|
65
65
|
it("returns an unsuccessful response", function() { with(this) {
|
66
66
|
server.handshake(message, false, function(response) {
|
67
67
|
assertEqual({
|
@@ -74,15 +74,15 @@ JS.ENV.Server.HandshakeSpec = JS.Test.describe("Server handshake", function() {
|
|
74
74
|
})
|
75
75
|
}})
|
76
76
|
}})
|
77
|
-
|
77
|
+
|
78
78
|
describe("missing supportedConnectionTypes", function() { with(this) {
|
79
79
|
before(function() { delete this.message.supportedConnectionTypes })
|
80
|
-
|
80
|
+
|
81
81
|
it("does not create a client", function() { with(this) {
|
82
82
|
expect(engine, "createClient").exactly(0)
|
83
83
|
server.handshake(message, false, function() {})
|
84
84
|
}})
|
85
|
-
|
85
|
+
|
86
86
|
it("returns an unsuccessful response", function() { with(this) {
|
87
87
|
server.handshake(message, false, function(response) {
|
88
88
|
assertEqual({
|
@@ -95,17 +95,17 @@ JS.ENV.Server.HandshakeSpec = JS.Test.describe("Server handshake", function() {
|
|
95
95
|
})
|
96
96
|
}})
|
97
97
|
}})
|
98
|
-
|
98
|
+
|
99
99
|
describe("with no matching supportedConnectionTypes", function() { with(this) {
|
100
100
|
before(function() { with(this) {
|
101
101
|
message.supportedConnectionTypes = ["iframe", "flash"]
|
102
102
|
}})
|
103
|
-
|
103
|
+
|
104
104
|
it("does not create a client", function() { with(this) {
|
105
105
|
expect(engine, "createClient").exactly(0)
|
106
106
|
server.handshake(message, false, function() {})
|
107
107
|
}})
|
108
|
-
|
108
|
+
|
109
109
|
it("returns an unsuccessful response", function() { with(this) {
|
110
110
|
server.handshake(message, false, function(response) {
|
111
111
|
assertEqual({
|
@@ -118,17 +118,17 @@ JS.ENV.Server.HandshakeSpec = JS.Test.describe("Server handshake", function() {
|
|
118
118
|
})
|
119
119
|
}})
|
120
120
|
}})
|
121
|
-
|
121
|
+
|
122
122
|
describe("with an error", function() { with(this) {
|
123
123
|
before(function() { with(this) {
|
124
124
|
message.error = "invalid"
|
125
125
|
}})
|
126
|
-
|
126
|
+
|
127
127
|
it("does not create a client", function() { with(this) {
|
128
128
|
expect(engine, "createClient").exactly(0)
|
129
129
|
server.handshake(message, false, function() {})
|
130
130
|
}})
|
131
|
-
|
131
|
+
|
132
132
|
it("returns an unsuccessful response", function() { with(this) {
|
133
133
|
server.handshake(message, false, function(response) {
|
134
134
|
assertEqual({
|
@@ -1,11 +1,11 @@
|
|
1
1
|
JS.ENV.IntegrationSteps = JS.Test.asyncSteps({
|
2
2
|
server: function(port, ssl, callback) {
|
3
3
|
var shared = __dirname + '/../../../examples/shared',
|
4
|
-
|
4
|
+
|
5
5
|
options = ssl
|
6
6
|
? { key: shared + '/server.key', cert: shared + '/server.crt' }
|
7
7
|
: null
|
8
|
-
|
8
|
+
|
9
9
|
this._adapter = new Faye.NodeAdapter({mount: "/bayeux", timeout: 2})
|
10
10
|
this._adapter.addExtension({
|
11
11
|
outgoing: function(message, callback) {
|
@@ -13,28 +13,28 @@ JS.ENV.IntegrationSteps = JS.Test.asyncSteps({
|
|
13
13
|
callback(message)
|
14
14
|
}
|
15
15
|
})
|
16
|
-
|
16
|
+
|
17
17
|
this._port = port
|
18
18
|
this._secure = ssl
|
19
19
|
this._adapter.listen(port, options, callback)
|
20
20
|
},
|
21
|
-
|
21
|
+
|
22
22
|
stop: function(callback) {
|
23
23
|
for (var id in this._clients) this._clients[id].disconnect()
|
24
24
|
var self = this
|
25
25
|
setTimeout(function() { self._adapter.stop(callback) }, 100)
|
26
26
|
},
|
27
|
-
|
27
|
+
|
28
28
|
client: function(name, channels, callback) {
|
29
29
|
var scheme = this._secure ? "https" : "http"
|
30
30
|
this._clients = this._clients || {}
|
31
31
|
this._inboxes = this._inboxes || {}
|
32
32
|
this._clients[name] = new Faye.Client(scheme + "://0.0.0.0:" + this._port + "/bayeux")
|
33
33
|
this._inboxes[name] = {}
|
34
|
-
|
34
|
+
|
35
35
|
var n = channels.length
|
36
36
|
if (n === 0) return this._clients[name].connect(callback)
|
37
|
-
|
37
|
+
|
38
38
|
for (var i = 0; i < n; i++)
|
39
39
|
(function(channel) {
|
40
40
|
var subscription = this._clients[name].subscribe(channel, function(message) {
|
@@ -47,12 +47,12 @@ JS.ENV.IntegrationSteps = JS.Test.asyncSteps({
|
|
47
47
|
})
|
48
48
|
}).call(this, channels[i]);
|
49
49
|
},
|
50
|
-
|
50
|
+
|
51
51
|
publish: function(name, channel, message, callback) {
|
52
52
|
this._clients[name].publish(channel, message)
|
53
53
|
setTimeout(callback, 100)
|
54
54
|
},
|
55
|
-
|
55
|
+
|
56
56
|
check_inbox: function(name, channel, messages, callback) {
|
57
57
|
var inbox = this._inboxes[name][channel] || []
|
58
58
|
this.assertEqual(messages, inbox)
|
@@ -62,69 +62,69 @@ JS.ENV.IntegrationSteps = JS.Test.asyncSteps({
|
|
62
62
|
|
63
63
|
JS.ENV.Server.IntegrationSpec = JS.Test.describe("Server integration", function() { with(this) {
|
64
64
|
include(IntegrationSteps)
|
65
|
-
|
65
|
+
|
66
66
|
sharedExamplesFor("message bus", function() { with(this) {
|
67
67
|
before(function() { with(this) {
|
68
68
|
server(8000, serverOptions.ssl)
|
69
69
|
client("alice", [])
|
70
70
|
client("bob", ["/foo"])
|
71
71
|
}})
|
72
|
-
|
72
|
+
|
73
73
|
after(function() { this.stop() })
|
74
|
-
|
74
|
+
|
75
75
|
it("delivers a message between clients", function() { with(this) {
|
76
76
|
publish("alice", "/foo", {hello: "world", extra: null})
|
77
77
|
check_inbox("bob", "/foo", [{hello: "world", extra: null, tagged: true}])
|
78
78
|
}})
|
79
|
-
|
79
|
+
|
80
80
|
it("does not deliver messages for unsubscribed channels", function() { with(this) {
|
81
81
|
publish("alice", "/bar", {hello: "world"})
|
82
82
|
check_inbox("bob", "/foo", [])
|
83
83
|
}})
|
84
|
-
|
84
|
+
|
85
85
|
it("delivers multiple messages", function() { with(this) {
|
86
86
|
publish("alice", "/foo", {hello: "world"})
|
87
87
|
publish("alice", "/foo", {hello: "world"})
|
88
88
|
check_inbox("bob", "/foo", [{hello: "world", tagged: true}, {hello: "world", tagged: true}])
|
89
89
|
}})
|
90
|
-
|
90
|
+
|
91
91
|
it("delivers multibyte strings", function() { with(this) {
|
92
92
|
publish("alice", "/foo", {hello: "Apple = "})
|
93
93
|
check_inbox("bob", "/foo", [{hello: "Apple = ", tagged: true}])
|
94
94
|
}})
|
95
95
|
}})
|
96
|
-
|
96
|
+
|
97
97
|
sharedExamplesFor("network transports", function() { with(this) {
|
98
98
|
describe("with HTTP transport", function() { with(this) {
|
99
99
|
before(function() { with(this) {
|
100
100
|
stub(Faye.Transport.WebSocket, "isUsable").yields([false])
|
101
101
|
}})
|
102
|
-
|
102
|
+
|
103
103
|
itShouldBehaveLike("message bus")
|
104
104
|
}})
|
105
|
-
|
105
|
+
|
106
106
|
describe("with WebSocket transport", function() { with(this) {
|
107
107
|
before(function() { with(this) {
|
108
108
|
stub(Faye.Transport.WebSocket, "isUsable").yields([true])
|
109
109
|
}})
|
110
|
-
|
110
|
+
|
111
111
|
itShouldBehaveLike("message bus")
|
112
112
|
}})
|
113
113
|
}})
|
114
|
-
|
114
|
+
|
115
115
|
describe("with HTTP server", function() { with(this) {
|
116
116
|
before(function() { with(this) {
|
117
117
|
this.serverOptions = {ssl: false}
|
118
118
|
}})
|
119
|
-
|
119
|
+
|
120
120
|
itShouldBehaveLike("network transports")
|
121
121
|
}})
|
122
|
-
|
122
|
+
|
123
123
|
describe("with HTTPS server", function() { with(this) {
|
124
124
|
before(function() { with(this) {
|
125
125
|
this.serverOptions = {ssl: true}
|
126
126
|
}})
|
127
|
-
|
127
|
+
|
128
128
|
itShouldBehaveLike("network transports")
|
129
129
|
}})
|
130
130
|
}})
|