faye 0.8.11 → 1.0.0

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.

Files changed (73) hide show
  1. data/{History.txt → CHANGELOG.md} +126 -105
  2. data/README.md +36 -0
  3. data/lib/faye-browser-min.js +2 -1
  4. data/lib/faye-browser-min.js.map +1 -8
  5. data/lib/faye-browser.js +923 -607
  6. data/lib/faye.rb +11 -5
  7. data/lib/faye/adapters/rack_adapter.rb +80 -85
  8. data/lib/faye/engines/connection.rb +7 -9
  9. data/lib/faye/engines/memory.rb +1 -0
  10. data/lib/faye/engines/proxy.rb +7 -6
  11. data/lib/faye/mixins/deferrable.rb +15 -0
  12. data/lib/faye/mixins/logging.rb +11 -22
  13. data/lib/faye/mixins/publisher.rb +9 -20
  14. data/lib/faye/protocol/channel.rb +2 -1
  15. data/lib/faye/protocol/client.rb +70 -48
  16. data/lib/faye/protocol/envelope.rb +24 -0
  17. data/lib/faye/protocol/extensible.rb +7 -4
  18. data/lib/faye/protocol/publication.rb +1 -1
  19. data/lib/faye/protocol/server.rb +8 -11
  20. data/lib/faye/protocol/socket.rb +6 -4
  21. data/lib/faye/protocol/subscription.rb +1 -1
  22. data/lib/faye/transport/http.rb +20 -27
  23. data/lib/faye/transport/local.rb +5 -5
  24. data/lib/faye/transport/transport.rb +42 -12
  25. data/lib/faye/transport/web_socket.rb +71 -38
  26. metadata +169 -137
  27. checksums.yaml +0 -7
  28. data/README.rdoc +0 -83
  29. data/spec/browser.html +0 -45
  30. data/spec/encoding_helper.rb +0 -7
  31. data/spec/install.sh +0 -78
  32. data/spec/javascript/channel_spec.js +0 -15
  33. data/spec/javascript/client_spec.js +0 -729
  34. data/spec/javascript/dispatcher_spec.js +0 -122
  35. data/spec/javascript/engine/memory_spec.js +0 -7
  36. data/spec/javascript/engine_spec.js +0 -417
  37. data/spec/javascript/faye_spec.js +0 -34
  38. data/spec/javascript/grammar_spec.js +0 -66
  39. data/spec/javascript/node_adapter_spec.js +0 -314
  40. data/spec/javascript/publisher_spec.js +0 -27
  41. data/spec/javascript/server/connect_spec.js +0 -168
  42. data/spec/javascript/server/disconnect_spec.js +0 -121
  43. data/spec/javascript/server/extensions_spec.js +0 -60
  44. data/spec/javascript/server/handshake_spec.js +0 -145
  45. data/spec/javascript/server/integration_spec.js +0 -131
  46. data/spec/javascript/server/publish_spec.js +0 -85
  47. data/spec/javascript/server/subscribe_spec.js +0 -247
  48. data/spec/javascript/server/unsubscribe_spec.js +0 -245
  49. data/spec/javascript/server_spec.js +0 -121
  50. data/spec/javascript/transport_spec.js +0 -135
  51. data/spec/node.js +0 -55
  52. data/spec/phantom.js +0 -17
  53. data/spec/ruby/channel_spec.rb +0 -17
  54. data/spec/ruby/client_spec.rb +0 -741
  55. data/spec/ruby/engine/memory_spec.rb +0 -7
  56. data/spec/ruby/engine_examples.rb +0 -427
  57. data/spec/ruby/faye_spec.rb +0 -30
  58. data/spec/ruby/grammar_spec.rb +0 -68
  59. data/spec/ruby/publisher_spec.rb +0 -27
  60. data/spec/ruby/rack_adapter_spec.rb +0 -241
  61. data/spec/ruby/server/connect_spec.rb +0 -170
  62. data/spec/ruby/server/disconnect_spec.rb +0 -120
  63. data/spec/ruby/server/extensions_spec.rb +0 -68
  64. data/spec/ruby/server/handshake_spec.rb +0 -143
  65. data/spec/ruby/server/integration_spec.rb +0 -133
  66. data/spec/ruby/server/publish_spec.rb +0 -81
  67. data/spec/ruby/server/subscribe_spec.rb +0 -247
  68. data/spec/ruby/server/unsubscribe_spec.rb +0 -247
  69. data/spec/ruby/server_spec.rb +0 -121
  70. data/spec/ruby/transport_spec.rb +0 -136
  71. data/spec/spec_helper.rb +0 -11
  72. data/spec/testswarm +0 -42
  73. data/spec/thin_proxy.rb +0 -37
@@ -1,85 +0,0 @@
1
- JS.ENV.Server.PublishSpec = JS.Test.describe("Server publish", function() { with(this) {
2
- before(function() { with(this) {
3
- this.engine = {}
4
- stub(Faye.Engine, "get").returns(engine)
5
- this.server = new Faye.Server()
6
-
7
- this.message = {channel: "/some/channel", data: "publish"}
8
- }})
9
-
10
- describe("publishing a message", function() { with(this) {
11
- it("tells the engine to publish the message", function() { with(this) {
12
- expect(engine, "publish").given(message)
13
- server.process(message, false, function() {})
14
- }})
15
-
16
- it("returns a successful response", function() { with(this) {
17
- stub(engine, "publish")
18
- server.process(message, false, function(response) {
19
- assertEqual([
20
- { channel: "/some/channel",
21
- successful: true
22
- }
23
- ], response)
24
- })
25
- }})
26
-
27
- describe("with an invalid channel", function() { with(this) {
28
- before(function() { with(this) {
29
- message.channel = "channel"
30
- }})
31
-
32
- it("does not tell the engine to publish the message", function() { with(this) {
33
- expect(engine, "publish").exactly(0)
34
- server.process(message, false, function() {})
35
- }})
36
-
37
- it("returns an unsuccessful response", function() { with(this) {
38
- stub(engine, "publish")
39
- server.process(message, false, function(response) {
40
- assertEqual([
41
- { channel: "channel",
42
- successful: false,
43
- error: "405:channel:Invalid channel"
44
- }
45
- ], response)
46
- })
47
- }})
48
- }})
49
-
50
- describe("with an error", function() { with(this) {
51
- before(function() { with(this) {
52
- message.error = "invalid"
53
- }})
54
-
55
- it("does not tell the engine to publish the message", function() { with(this) {
56
- expect(engine, "publish").exactly(0)
57
- server.process(message, false, function() {})
58
- }})
59
-
60
- it("returns an unsuccessful response", function() { with(this) {
61
- stub(engine, "publish")
62
- server.process(message, false, function(response) {
63
- assertEqual([
64
- { channel: "/some/channel",
65
- successful: false,
66
- error: "invalid"
67
- }
68
- ], response)
69
- })
70
- }})
71
- }})
72
-
73
- describe("to an invalid channel", function() { with(this) {
74
- before(function() { with(this) {
75
- message.channel = "/invalid/*"
76
- }})
77
-
78
- it("does not tell the engine to publish the message", function() { with(this) {
79
- expect(engine, "publish").exactly(0)
80
- server.process(message, false, function() {})
81
- }})
82
- }})
83
- }})
84
- }})
85
-
@@ -1,247 +0,0 @@
1
- JS.ENV.Server.SubscribeSpec = JS.Test.describe("Server subscribe", function() { with(this) {
2
- before(function() { with(this) {
3
- this.engine = {}
4
- stub(Faye.Engine, "get").returns(engine)
5
- this.server = new Faye.Server()
6
- }})
7
-
8
- describe("#subscribe", function() { with(this) {
9
- before(function() { with(this) {
10
- this.clientId = "fakeclientid"
11
- this.message = {channel: "/meta/subscribe",
12
- clientId: "fakeclientid",
13
- subscription: "/foo"}
14
- }})
15
-
16
- describe("with valid parameters", function() { with(this) {
17
- before(function() { with(this) {
18
- expect(engine, "clientExists").given(clientId).yielding([true])
19
- }})
20
-
21
- it("subscribes the client to the channel", function() { with(this) {
22
- expect(engine, "subscribe").given(clientId, "/foo")
23
- server.subscribe(message, false, function() {})
24
- }})
25
-
26
- it("returns a successful response", function() { with(this) {
27
- stub(engine, "subscribe")
28
- server.subscribe(message, false, function(response) {
29
- assertEqual({
30
- channel: "/meta/subscribe",
31
- successful: true,
32
- clientId: clientId,
33
- subscription: "/foo"
34
- }, response)
35
- })
36
- }})
37
-
38
- describe("with a list of subscriptions", function() { with(this) {
39
- before(function() { with(this) {
40
- message.subscription = ["/foo", "/bar"]
41
- }})
42
-
43
- it("creates multiple subscriptions", function() { with(this) {
44
- expect(engine, "subscribe").given(clientId, "/foo")
45
- expect(engine, "subscribe").given(clientId, "/bar")
46
- server.subscribe(message, false, function() {})
47
- }})
48
-
49
- it("returns a successful response", function() { with(this) {
50
- stub(engine, "subscribe")
51
- server.subscribe(message, false, function(response) {
52
- assertEqual({
53
- channel: "/meta/subscribe",
54
- successful: true,
55
- clientId: clientId,
56
- subscription: ["/foo", "/bar"]
57
- }, response)
58
- })
59
- }})
60
- }})
61
-
62
- describe("with a subscription pattern", function() { with(this) {
63
- before(function() { with(this) {
64
- message.subscription = "/foo/**"
65
- }})
66
-
67
- it("subscribes the client to the channel pattern", function() { with(this) {
68
- expect(engine, "subscribe").given(clientId, "/foo/**")
69
- server.subscribe(message, false, function() {})
70
- }})
71
-
72
- it("returns a successful response", function() { with(this) {
73
- stub(engine, "subscribe")
74
- server.subscribe(message, false, function(response) {
75
- assertEqual({
76
- channel: "/meta/subscribe",
77
- successful: true,
78
- clientId: clientId,
79
- subscription: "/foo/**"
80
- }, response)
81
- })
82
- }})
83
- }})
84
- }})
85
-
86
- describe("with an unknown client", function() { with(this) {
87
- before(function() { with(this) {
88
- expect(engine, "clientExists").given(clientId).yielding([false])
89
- }})
90
-
91
- it("does not subscribe the client to the channel", function() { with(this) {
92
- expect(engine, "subscribe").exactly(0)
93
- server.subscribe(message, false, function() {})
94
- }})
95
-
96
- it("returns an unsuccessful response", function() { with(this) {
97
- server.subscribe(message, false, function(response) {
98
- assertEqual({
99
- channel: "/meta/subscribe",
100
- successful: false,
101
- error: "401:fakeclientid:Unknown client",
102
- clientId: clientId,
103
- subscription: "/foo"
104
- }, response)
105
- })
106
- }})
107
- }})
108
-
109
- describe("missing clientId", function() { with(this) {
110
- before(function() { with(this) {
111
- delete message.clientId
112
- expect(engine, "clientExists").given(undefined).yielding([false])
113
- }})
114
-
115
- it("does not subscribe the client to the channel", function() { with(this) {
116
- expect(engine, "subscribe").exactly(0)
117
- server.subscribe(message, false, function() {})
118
- }})
119
-
120
- it("returns an unsuccessful response", function() { with(this) {
121
- server.subscribe(message, false, function(response) {
122
- assertEqual({
123
- channel: "/meta/subscribe",
124
- successful: false,
125
- error: "402:clientId:Missing required parameter",
126
- subscription: "/foo"
127
- }, response)
128
- })
129
- }})
130
- }})
131
-
132
- describe("missing subscription", function() { with(this) {
133
- before(function() { with(this) {
134
- delete message.subscription
135
- expect(engine, "clientExists").given(clientId).yielding([true])
136
- }})
137
-
138
- it("does not subscribe the client to the channel", function() { with(this) {
139
- expect(engine, "subscribe").exactly(0)
140
- server.subscribe(message, false, function() {})
141
- }})
142
-
143
- it("returns an unsuccessful response", function() { with(this) {
144
- server.subscribe(message, false, function(response) {
145
- assertEqual({
146
- channel: "/meta/subscribe",
147
- successful: false,
148
- error: "402:subscription:Missing required parameter",
149
- clientId: clientId,
150
- subscription: []
151
- }, response)
152
- })
153
- }})
154
- }})
155
-
156
- describe("with an invalid channel", function() { with(this) {
157
- before(function() { with(this) {
158
- message.subscription = "foo"
159
- expect(engine, "clientExists").given(clientId).yielding([true])
160
- }})
161
-
162
- it("does not subscribe the client to the channel", function() { with(this) {
163
- expect(engine, "subscribe").exactly(0)
164
- server.subscribe(message, false, function() {})
165
- }})
166
-
167
- it("returns an unsuccessful response", function() { with(this) {
168
- server.subscribe(message, false, function(response) {
169
- assertEqual({
170
- channel: "/meta/subscribe",
171
- successful: false,
172
- error: "405:foo:Invalid channel",
173
- clientId: clientId,
174
- subscription: "foo"
175
- }, response)
176
- })
177
- }})
178
- }})
179
-
180
- describe("with a /meta/* channel", function() { with(this) {
181
- before(function() { with(this) {
182
- message.subscription = "/meta/foo"
183
- expect(engine, "clientExists").given(clientId).yielding([true])
184
- }})
185
-
186
- it("does not subscribe the client to the channel", function() { with(this) {
187
- expect(engine, "subscribe").exactly(0)
188
- server.subscribe(message, false, function() {})
189
- }})
190
-
191
- it("returns an unsuccessful response", function() { with(this) {
192
- server.subscribe(message, false, function(response) {
193
- assertEqual({
194
- channel: "/meta/subscribe",
195
- successful: false,
196
- error: "403:/meta/foo:Forbidden channel",
197
- clientId: clientId,
198
- subscription: "/meta/foo"
199
- }, response)
200
- })
201
- }})
202
-
203
- it("subscribes local clients to the channel", function() { with(this) {
204
- expect(engine, "subscribe").given(clientId, "/meta/foo")
205
- server.subscribe(message, true, function() {})
206
- }})
207
-
208
- it("returns a successful response for local clients", function() { with(this) {
209
- stub(engine, "subscribe")
210
- server.subscribe(message, true, function(response) {
211
- assertEqual({
212
- channel: "/meta/subscribe",
213
- successful: true,
214
- clientId: clientId,
215
- subscription: "/meta/foo"
216
- }, response)
217
- })
218
- }})
219
- }})
220
-
221
- describe("with an error", function() { with(this) {
222
- before(function() { with(this) {
223
- message.error = "invalid"
224
- expect(engine, "clientExists").given(clientId).yielding([true])
225
- }})
226
-
227
- it("does not subscribe the client to the channel", function() { with(this) {
228
- expect(engine, "subscribe").exactly(0)
229
- server.subscribe(message, false, function() {})
230
- }})
231
-
232
- it("returns an unsuccessful response", function(resume) { with(this) {
233
- server.subscribe(message, false, function(response) {
234
- resume(function() {
235
- assertEqual({
236
- channel: "/meta/subscribe",
237
- successful: false,
238
- error: "invalid",
239
- clientId: clientId,
240
- subscription: "/foo"
241
- }, response)
242
- })
243
- })
244
- }})
245
- }})
246
- }})
247
- }})
@@ -1,245 +0,0 @@
1
- JS.ENV.Server.UnsubscribeSpec = JS.Test.describe("Server unsubscribe", function() { with(this) {
2
- before(function() { with(this) {
3
- this.engine = {}
4
- stub(Faye.Engine, "get").returns(engine)
5
- this.server = new Faye.Server()
6
- }})
7
-
8
- describe("#unsubscribe", function() { with(this) {
9
- before(function() { with(this) {
10
- this.clientId = "fakeclientid"
11
- this.message = {channel: "/meta/unsubscribe",
12
- clientId: "fakeclientid",
13
- subscription: "/foo"}
14
- }})
15
-
16
- describe("with valid parameters", function() { with(this) {
17
- before(function() { with(this) {
18
- expect(engine, "clientExists").given(clientId).yielding([true])
19
- }})
20
-
21
- it("unsubscribes the client from the channel", function() { with(this) {
22
- expect(engine, "unsubscribe").given(clientId, "/foo")
23
- server.unsubscribe(message, false, function() {})
24
- }})
25
-
26
- it("returns a successful response", function() { with(this) {
27
- stub(engine, "unsubscribe")
28
- server.unsubscribe(message, false, function(response) {
29
- assertEqual({
30
- channel: "/meta/unsubscribe",
31
- successful: true,
32
- clientId: clientId,
33
- subscription: "/foo"
34
- }, response)
35
- })
36
- }})
37
-
38
- describe("with a list of subscriptions", function() { with(this) {
39
- before(function() { with(this) {
40
- message.subscription = ["/foo", "/bar"]
41
- }})
42
-
43
- it("destroys multiple subscriptions", function() { with(this) {
44
- expect(engine, "unsubscribe").given(clientId, "/foo")
45
- expect(engine, "unsubscribe").given(clientId, "/bar")
46
- server.unsubscribe(message, false, function() {})
47
- }})
48
-
49
- it("returns a successful response", function() { with(this) {
50
- stub(engine, "unsubscribe")
51
- server.unsubscribe(message, false, function(response) {
52
- assertEqual({
53
- channel: "/meta/unsubscribe",
54
- successful: true,
55
- clientId: clientId,
56
- subscription: ["/foo", "/bar"]
57
- }, response)
58
- })
59
- }})
60
- }})
61
-
62
- describe("with a subscription pattern", function() { with(this) {
63
- before(function() { with(this) {
64
- message.subscription = "/foo/**"
65
- }})
66
-
67
- it("destroys the subscription to the channel pattern", function() { with(this) {
68
- expect(engine, "unsubscribe").given(clientId, "/foo/**")
69
- server.unsubscribe(message, false, function() {})
70
- }})
71
-
72
- it("returns a successful response", function() { with(this) {
73
- stub(engine, "unsubscribe")
74
- server.unsubscribe(message, false, function(response) {
75
- assertEqual({
76
- channel: "/meta/unsubscribe",
77
- successful: true,
78
- clientId: clientId,
79
- subscription: "/foo/**"
80
- }, response)
81
- })
82
- }})
83
- }})
84
- }})
85
-
86
- describe("with an unknown client", function() { with(this) {
87
- before(function() { with(this) {
88
- expect(engine, "clientExists").given(clientId).yielding([false])
89
- }})
90
-
91
- it("does not unsubscribe the client from the channel", function() { with(this) {
92
- expect(engine, "unsubscribe").exactly(0)
93
- server.unsubscribe(message, false, function() {})
94
- }})
95
-
96
- it("returns an unsuccessful response", function() { with(this) {
97
- server.unsubscribe(message, false, function(response) {
98
- assertEqual({
99
- channel: "/meta/unsubscribe",
100
- successful: false,
101
- error: "401:fakeclientid:Unknown client",
102
- clientId: clientId,
103
- subscription: "/foo"
104
- }, response)
105
- })
106
- }})
107
- }})
108
-
109
- describe("missing clientId", function() { with(this) {
110
- before(function() { with(this) {
111
- delete message.clientId
112
- expect(engine, "clientExists").given(undefined).yielding([false])
113
- }})
114
-
115
- it("does not unsubscribe the client from the channel", function() { with(this) {
116
- expect(engine, "unsubscribe").exactly(0)
117
- server.unsubscribe(message, false, function() {})
118
- }})
119
-
120
- it("returns an unsuccessful response", function() { with(this) {
121
- server.unsubscribe(message, false, function(response) {
122
- assertEqual({
123
- channel: "/meta/unsubscribe",
124
- successful: false,
125
- error: "402:clientId:Missing required parameter",
126
- subscription: "/foo"
127
- }, response)
128
- })
129
- }})
130
- }})
131
-
132
- describe("missing subscription", function() { with(this) {
133
- before(function() { with(this) {
134
- delete message.subscription
135
- expect(engine, "clientExists").given(clientId).yielding([true])
136
- }})
137
-
138
- it("does not unsubscribe the client from the channel", function() { with(this) {
139
- expect(engine, "unsubscribe").exactly(0)
140
- server.unsubscribe(message, false, function() {})
141
- }})
142
-
143
- it("returns an unsuccessful response", function() { with(this) {
144
- server.unsubscribe(message, false, function(response) {
145
- assertEqual({
146
- channel: "/meta/unsubscribe",
147
- successful: false,
148
- error: "402:subscription:Missing required parameter",
149
- clientId: clientId,
150
- subscription: []
151
- }, response)
152
- })
153
- }})
154
- }})
155
-
156
- describe("with an invalid channel", function() { with(this) {
157
- before(function() { with(this) {
158
- message.subscription = "foo"
159
- expect(engine, "clientExists").given(clientId).yielding([true])
160
- }})
161
-
162
- it("does not unsubscribe the client from the channel", function() { with(this) {
163
- expect(engine, "unsubscribe").exactly(0)
164
- server.unsubscribe(message, false, function() {})
165
- }})
166
-
167
- it("returns an unsuccessful response", function() { with(this) {
168
- server.unsubscribe(message, false, function(response) {
169
- assertEqual({
170
- channel: "/meta/unsubscribe",
171
- successful: false,
172
- error: "405:foo:Invalid channel",
173
- clientId: clientId,
174
- subscription: "foo"
175
- }, response)
176
- })
177
- }})
178
- }})
179
-
180
- describe("with a /meta/* channel", function() { with(this) {
181
- before(function() { with(this) {
182
- message.subscription = "/meta/foo"
183
- expect(engine, "clientExists").given(clientId).yielding([true])
184
- }})
185
-
186
- it("does not unsubscribe the client from the channel", function() { with(this) {
187
- expect(engine, "unsubscribe").exactly(0)
188
- server.unsubscribe(message, false, function() {})
189
- }})
190
-
191
- it("returns an unsuccessful response", function() { with(this) {
192
- server.unsubscribe(message, false, function(response) {
193
- assertEqual({
194
- channel: "/meta/unsubscribe",
195
- successful: false,
196
- error: "403:/meta/foo:Forbidden channel",
197
- clientId: clientId,
198
- subscription: "/meta/foo"
199
- }, response)
200
- })
201
- }})
202
-
203
- it("unsubscribes local clients from the channel", function() { with(this) {
204
- expect(engine, "unsubscribe").given(clientId, "/meta/foo")
205
- server.unsubscribe(message, true, function() {})
206
- }})
207
-
208
- it("returns a successful response for local clients", function() { with(this) {
209
- stub(engine, "unsubscribe")
210
- server.unsubscribe(message, true, function(response) {
211
- assertEqual({
212
- channel: "/meta/unsubscribe",
213
- successful: true,
214
- clientId: clientId,
215
- subscription: "/meta/foo"
216
- }, response)
217
- })
218
- }})
219
- }})
220
-
221
- describe("with an error", function() { with(this) {
222
- before(function() { with(this) {
223
- message.error = "invalid"
224
- expect(engine, "clientExists").given(clientId).yielding([true])
225
- }})
226
-
227
- it("does not unsubscribe the client from the channel", function() { with(this) {
228
- expect(engine, "unsubscribe").exactly(0)
229
- server.unsubscribe(message, false, function() {})
230
- }})
231
-
232
- it("returns an unsuccessful response", function() { with(this) {
233
- server.unsubscribe(message, false, function(response) {
234
- assertEqual({
235
- channel: "/meta/unsubscribe",
236
- successful: false,
237
- error: "invalid",
238
- clientId: clientId,
239
- subscription: "/foo"
240
- }, response)
241
- })
242
- }})
243
- }})
244
- }})
245
- }})