wamp_client 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +34 -32
- data/lib/wamp/client/auth.rb +0 -27
- data/lib/wamp/client/check.rb +0 -27
- data/lib/wamp/client/connection.rb +40 -113
- data/lib/wamp/client/event.rb +78 -0
- data/lib/wamp/client/manager/base.rb +39 -0
- data/lib/wamp/client/manager/base_multiple.rb +37 -0
- data/lib/wamp/client/manager/establish.rb +168 -0
- data/lib/wamp/client/manager/registration.rb +183 -0
- data/lib/wamp/client/manager/require.rb +3 -0
- data/lib/wamp/client/manager/subscription.rb +55 -0
- data/lib/wamp/client/request/base.rb +125 -0
- data/lib/wamp/client/request/call.rb +111 -0
- data/lib/wamp/client/request/publish.rb +72 -0
- data/lib/wamp/client/request/register.rb +79 -0
- data/lib/wamp/client/request/require.rb +6 -0
- data/lib/wamp/client/request/subscribe.rb +78 -0
- data/lib/wamp/client/request/unregister.rb +71 -0
- data/lib/wamp/client/request/unsubscribe.rb +72 -0
- data/lib/wamp/client/response.rb +136 -0
- data/lib/wamp/client/serializer.rb +0 -29
- data/lib/wamp/client/session.rb +172 -839
- data/lib/wamp/client/transport/base.rb +4 -77
- data/lib/wamp/client/transport/event_machine_base.rb +0 -27
- data/lib/wamp/client/transport/faye_web_socket.rb +4 -31
- data/lib/wamp/client/transport/web_socket_event_machine.rb +3 -30
- data/lib/wamp/client/version.rb +1 -28
- data/lib/wamp/client.rb +1 -28
- data/spec/spec_helper.rb +3 -137
- data/spec/support/faye_web_socket_client_stub.rb +43 -0
- data/spec/support/test_transport.rb +50 -0
- data/spec/support/web_socket_event_machine_client_stub.rb +39 -0
- data/spec/wamp/client/connection_spec.rb +4 -4
- data/spec/wamp/client/session_spec.rb +135 -135
- data/spec/wamp/client/transport_spec.rb +2 -2
- data/wamp_client.gemspec +10 -9
- metadata +59 -38
- data/lib/wamp/client/defer.rb +0 -70
@@ -1,18 +1,18 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Wamp::Client::Session do
|
4
|
-
let (:transport) {
|
4
|
+
let (:transport) { TestTransport.new({}) }
|
5
5
|
let (:session) { Wamp::Client::Session.new(transport) }
|
6
6
|
|
7
7
|
describe 'establishment' do
|
8
8
|
|
9
9
|
before(:each) do
|
10
10
|
@join_count = 0
|
11
|
-
session.
|
11
|
+
session.on :join do |details|
|
12
12
|
@join_count += 1
|
13
13
|
end
|
14
14
|
@leave_count = 0
|
15
|
-
session.
|
15
|
+
session.on :leave do |reason, details|
|
16
16
|
@leave_count += 1
|
17
17
|
end
|
18
18
|
end
|
@@ -48,7 +48,7 @@ describe Wamp::Client::Session do
|
|
48
48
|
expect(@leave_count).to eq(0)
|
49
49
|
|
50
50
|
# Check Exception
|
51
|
-
expect { session.join('test') }.to
|
51
|
+
expect { session.join('test') }.to raise_error(RuntimeError)
|
52
52
|
|
53
53
|
end
|
54
54
|
|
@@ -71,7 +71,7 @@ describe Wamp::Client::Session do
|
|
71
71
|
it 'performs a connect then client initiated goodbye' do
|
72
72
|
|
73
73
|
# Check Exception
|
74
|
-
expect { session.leave('felt.like.it') }.to
|
74
|
+
expect { session.leave('felt.like.it') }.to raise_error(RuntimeError)
|
75
75
|
|
76
76
|
session.join('test')
|
77
77
|
welcome = Wamp::Client::Message::Welcome.new(1234, {})
|
@@ -85,7 +85,7 @@ describe Wamp::Client::Session do
|
|
85
85
|
expect(session.id).to eq(1234)
|
86
86
|
expect(session.realm).to eq('test')
|
87
87
|
expect(session.is_open?).to eq(true)
|
88
|
-
expect(session.
|
88
|
+
expect(session.establish.goodbye_sent).to eq(true)
|
89
89
|
expect(@leave_count).to eq(0)
|
90
90
|
|
91
91
|
# Send Goodbye response from server
|
@@ -97,7 +97,7 @@ describe Wamp::Client::Session do
|
|
97
97
|
expect(session.id).to be_nil
|
98
98
|
expect(session.is_open?).to eq(false)
|
99
99
|
expect(session.realm).to be_nil
|
100
|
-
expect(session.
|
100
|
+
expect(session.establish.goodbye_sent).to eq(false)
|
101
101
|
expect(@leave_count).to eq(1)
|
102
102
|
|
103
103
|
end
|
@@ -119,7 +119,7 @@ describe Wamp::Client::Session do
|
|
119
119
|
expect(session.id).to be_nil
|
120
120
|
expect(session.is_open?).to eq(false)
|
121
121
|
expect(session.realm).to be_nil
|
122
|
-
expect(session.
|
122
|
+
expect(session.establish.goodbye_sent).to eq(false)
|
123
123
|
expect(@leave_count).to eq(1)
|
124
124
|
|
125
125
|
end
|
@@ -130,7 +130,7 @@ describe Wamp::Client::Session do
|
|
130
130
|
|
131
131
|
before(:each) do
|
132
132
|
# Check Exception
|
133
|
-
expect { session.subscribe('test.topic', nil, {test: 1}) }.to
|
133
|
+
expect { session.subscribe('test.topic', nil, {test: 1}) }.to raise_error(RuntimeError)
|
134
134
|
|
135
135
|
session.join('test')
|
136
136
|
welcome = Wamp::Client::Message::Welcome.new(1234, {})
|
@@ -141,8 +141,8 @@ describe Wamp::Client::Session do
|
|
141
141
|
it 'adds subscribe request to queue' do
|
142
142
|
session.subscribe('test.topic', lambda {}, {test: 1})
|
143
143
|
|
144
|
-
expect(session.
|
145
|
-
request_id = session.
|
144
|
+
expect(session.request[:subscribe].requests.count).to eq(1)
|
145
|
+
request_id = session.request[:subscribe].requests.keys.first
|
146
146
|
|
147
147
|
# Check the transport messages
|
148
148
|
expect(transport.messages.count).to eq(1)
|
@@ -152,11 +152,11 @@ describe Wamp::Client::Session do
|
|
152
152
|
expect(transport.messages[0][3]).to eq('test.topic')
|
153
153
|
|
154
154
|
# Check the request dictionary
|
155
|
-
expect(session.
|
156
|
-
expect(session.
|
155
|
+
expect(session.request[:subscribe].requests[request_id][:t]).to eq('test.topic')
|
156
|
+
expect(session.request[:subscribe].requests[request_id][:o]).to eq({test: 1})
|
157
157
|
|
158
158
|
# Check the subscriptions
|
159
|
-
expect(session.
|
159
|
+
expect(session.subscription.objects.count).to eq(0)
|
160
160
|
end
|
161
161
|
|
162
162
|
it 'confirms subscription' do
|
@@ -170,7 +170,7 @@ describe Wamp::Client::Session do
|
|
170
170
|
expect(details).to eq({topic: 'test.topic', type: 'subscribe', session: session})
|
171
171
|
end
|
172
172
|
|
173
|
-
request_id = session.
|
173
|
+
request_id = session.request[:subscribe].requests.keys.first
|
174
174
|
|
175
175
|
expect(count).to eq(0)
|
176
176
|
|
@@ -181,12 +181,12 @@ describe Wamp::Client::Session do
|
|
181
181
|
expect(count).to eq(1)
|
182
182
|
|
183
183
|
# Check that the requests are empty
|
184
|
-
expect(session.
|
184
|
+
expect(session.request[:subscribe].requests.count).to eq(0)
|
185
185
|
|
186
186
|
# Check the subscriptions
|
187
|
-
expect(session.
|
188
|
-
expect(session.
|
189
|
-
expect(session.
|
187
|
+
expect(session.subscription.objects.count).to eq(1)
|
188
|
+
expect(session.subscription.objects[3456].topic).to eq('test.topic')
|
189
|
+
expect(session.subscription.objects[3456].options).to eq({test: 1})
|
190
190
|
|
191
191
|
end
|
192
192
|
|
@@ -200,7 +200,7 @@ describe Wamp::Client::Session do
|
|
200
200
|
expect(details).to eq({fail: true, topic: 'test.topic', type: 'subscribe', session: session})
|
201
201
|
end
|
202
202
|
|
203
|
-
request_id = session.
|
203
|
+
request_id = session.request[:subscribe].requests.keys.first
|
204
204
|
|
205
205
|
# Generate server response
|
206
206
|
error = Wamp::Client::Message::Error.new(Wamp::Client::Message::Types::SUBSCRIBE,
|
@@ -210,10 +210,10 @@ describe Wamp::Client::Session do
|
|
210
210
|
expect(count).to eq(1)
|
211
211
|
|
212
212
|
# Check that the requests are empty
|
213
|
-
expect(session.
|
213
|
+
expect(session.request[:subscribe].requests.count).to eq(0)
|
214
214
|
|
215
215
|
# Check the subscriptions
|
216
|
-
expect(session.
|
216
|
+
expect(session.subscription.objects.count).to eq(0)
|
217
217
|
end
|
218
218
|
|
219
219
|
it 'receives an event' do
|
@@ -222,13 +222,13 @@ describe Wamp::Client::Session do
|
|
222
222
|
handler = lambda do |args, kwargs, details|
|
223
223
|
count += 1
|
224
224
|
|
225
|
-
expect(details).to eq({test:1, publication:7890, session: session})
|
225
|
+
expect(details).to eq({test:1, publication:7890, session: session, topic: "test.topic"})
|
226
226
|
expect(args).to eq([2])
|
227
227
|
expect(kwargs).to eq({param: 'value'})
|
228
228
|
end
|
229
229
|
|
230
230
|
session.subscribe('test.topic', handler, {test: 1})
|
231
|
-
request_id = session.
|
231
|
+
request_id = session.request[:subscribe].requests.keys.first
|
232
232
|
|
233
233
|
expect(count).to eq(0)
|
234
234
|
|
@@ -252,7 +252,7 @@ describe Wamp::Client::Session do
|
|
252
252
|
|
253
253
|
before(:each) do
|
254
254
|
# Check Exception
|
255
|
-
expect { session.unsubscribe(nil) }.to
|
255
|
+
expect { session.unsubscribe(nil) }.to raise_error(RuntimeError)
|
256
256
|
|
257
257
|
session.join('test')
|
258
258
|
welcome = Wamp::Client::Message::Welcome.new(1234, {})
|
@@ -263,7 +263,7 @@ describe Wamp::Client::Session do
|
|
263
263
|
end
|
264
264
|
|
265
265
|
# Get the request ID
|
266
|
-
@request_id = session.
|
266
|
+
@request_id = session.request[:subscribe].requests.keys.first
|
267
267
|
|
268
268
|
# Generate server response
|
269
269
|
subscribed = Wamp::Client::Message::Subscribed.new(@request_id, 3456)
|
@@ -275,7 +275,7 @@ describe Wamp::Client::Session do
|
|
275
275
|
it 'adds unsubscribe request to the queue' do
|
276
276
|
session.unsubscribe(@subscription)
|
277
277
|
|
278
|
-
@request_id = session.
|
278
|
+
@request_id = session.request[:unsubscribe].requests.keys.first
|
279
279
|
|
280
280
|
# Check the transport messages
|
281
281
|
expect(transport.messages.count).to eq(1)
|
@@ -284,10 +284,10 @@ describe Wamp::Client::Session do
|
|
284
284
|
expect(transport.messages[0][2]).to eq(@subscription.id)
|
285
285
|
|
286
286
|
# Check the request dictionary
|
287
|
-
expect(session.
|
287
|
+
expect(session.request[:unsubscribe].requests[@request_id]).not_to be_nil
|
288
288
|
|
289
289
|
# Check the subscriptions
|
290
|
-
expect(session.
|
290
|
+
expect(session.subscription.objects.count).to eq(1)
|
291
291
|
|
292
292
|
end
|
293
293
|
|
@@ -302,7 +302,7 @@ describe Wamp::Client::Session do
|
|
302
302
|
expect(details).to eq({topic: 'test.topic', type: 'unsubscribe', session: session})
|
303
303
|
end
|
304
304
|
|
305
|
-
@request_id = session.
|
305
|
+
@request_id = session.request[:unsubscribe].requests.keys.first
|
306
306
|
|
307
307
|
expect(count).to eq(0)
|
308
308
|
|
@@ -311,10 +311,10 @@ describe Wamp::Client::Session do
|
|
311
311
|
transport.receive_message(unsubscribed.payload)
|
312
312
|
|
313
313
|
# Check the request dictionary
|
314
|
-
expect(session.
|
314
|
+
expect(session.request[:unsubscribe].requests.count).to eq(0)
|
315
315
|
|
316
316
|
# Check the subscriptions
|
317
|
-
expect(session.
|
317
|
+
expect(session.subscription.objects.count).to eq(0)
|
318
318
|
|
319
319
|
end
|
320
320
|
|
@@ -322,17 +322,17 @@ describe Wamp::Client::Session do
|
|
322
322
|
|
323
323
|
@subscription.unsubscribe
|
324
324
|
|
325
|
-
@request_id = session.
|
325
|
+
@request_id = session.request[:unsubscribe].requests.keys.first
|
326
326
|
|
327
327
|
# Generate Server Response
|
328
328
|
unsubscribed = Wamp::Client::Message::Unsubscribed.new(@request_id)
|
329
329
|
transport.receive_message(unsubscribed.payload)
|
330
330
|
|
331
331
|
# Check the request dictionary
|
332
|
-
expect(session.
|
332
|
+
expect(session.request[:unsubscribe].requests.count).to eq(0)
|
333
333
|
|
334
334
|
# Check the subscriptions
|
335
|
-
expect(session.
|
335
|
+
expect(session.subscription.objects.count).to eq(0)
|
336
336
|
|
337
337
|
end
|
338
338
|
|
@@ -347,7 +347,7 @@ describe Wamp::Client::Session do
|
|
347
347
|
expect(details).to eq({fail: true, topic: 'test.topic', type: 'unsubscribe', session: session})
|
348
348
|
end
|
349
349
|
|
350
|
-
@request_id = session.
|
350
|
+
@request_id = session.request[:unsubscribe].requests.keys.first
|
351
351
|
|
352
352
|
expect(count).to eq(0)
|
353
353
|
|
@@ -359,10 +359,10 @@ describe Wamp::Client::Session do
|
|
359
359
|
expect(count).to eq(1)
|
360
360
|
|
361
361
|
# Check the request dictionary
|
362
|
-
expect(session.
|
362
|
+
expect(session.request[:unsubscribe].requests.count).to eq(0)
|
363
363
|
|
364
364
|
# Check the subscriptions
|
365
|
-
expect(session.
|
365
|
+
expect(session.subscription.objects.count).to eq(1)
|
366
366
|
|
367
367
|
end
|
368
368
|
|
@@ -372,7 +372,7 @@ describe Wamp::Client::Session do
|
|
372
372
|
|
373
373
|
before(:each) do
|
374
374
|
# Check Exception
|
375
|
-
expect { session.publish('test.topic') }.to
|
375
|
+
expect { session.publish('test.topic') }.to raise_error(RuntimeError)
|
376
376
|
|
377
377
|
session.join('test')
|
378
378
|
welcome = Wamp::Client::Message::Welcome.new(1234, {})
|
@@ -384,7 +384,7 @@ describe Wamp::Client::Session do
|
|
384
384
|
it 'adds a publish to the publish request queue' do
|
385
385
|
session.publish('test.topic', nil, nil, {acknowledge:true})
|
386
386
|
|
387
|
-
@request_id = session.
|
387
|
+
@request_id = session.request[:publish].requests.keys.first
|
388
388
|
|
389
389
|
# Check the transport messages
|
390
390
|
expect(transport.messages.count).to eq(1)
|
@@ -393,7 +393,7 @@ describe Wamp::Client::Session do
|
|
393
393
|
expect(transport.messages[0][2]).to eq({acknowledge:true})
|
394
394
|
|
395
395
|
# Check the request dictionary
|
396
|
-
expect(session.
|
396
|
+
expect(session.request[:publish].requests[@request_id]).not_to be_nil
|
397
397
|
|
398
398
|
end
|
399
399
|
|
@@ -406,7 +406,7 @@ describe Wamp::Client::Session do
|
|
406
406
|
expect(transport.messages.count).to eq(1)
|
407
407
|
|
408
408
|
# Check the request dictionary
|
409
|
-
expect(session.
|
409
|
+
expect(session.request[:publish].requests.count).to eq(0)
|
410
410
|
|
411
411
|
end
|
412
412
|
|
@@ -423,7 +423,7 @@ describe Wamp::Client::Session do
|
|
423
423
|
expect(details).to eq({topic: 'test.topic', type: 'publish', session: session, publication: 5678})
|
424
424
|
end
|
425
425
|
|
426
|
-
@request_id = session.
|
426
|
+
@request_id = session.request[:publish].requests.keys.first
|
427
427
|
|
428
428
|
expect(count).to eq(0)
|
429
429
|
|
@@ -432,7 +432,7 @@ describe Wamp::Client::Session do
|
|
432
432
|
transport.receive_message(published.payload)
|
433
433
|
|
434
434
|
# Check the request dictionary
|
435
|
-
expect(session.
|
435
|
+
expect(session.request[:publish].requests.count).to eq(0)
|
436
436
|
|
437
437
|
expect(count).to eq(1)
|
438
438
|
|
@@ -449,7 +449,7 @@ describe Wamp::Client::Session do
|
|
449
449
|
expect(details).to eq({fail: true, topic: 'test.topic', type: 'publish', session: session})
|
450
450
|
end
|
451
451
|
|
452
|
-
@request_id = session.
|
452
|
+
@request_id = session.request[:publish].requests.keys.first
|
453
453
|
|
454
454
|
expect(count).to eq(0)
|
455
455
|
|
@@ -461,7 +461,7 @@ describe Wamp::Client::Session do
|
|
461
461
|
expect(count).to eq(1)
|
462
462
|
|
463
463
|
# Check the request dictionary
|
464
|
-
expect(session.
|
464
|
+
expect(session.request[:publish].requests.count).to eq(0)
|
465
465
|
|
466
466
|
end
|
467
467
|
|
@@ -471,7 +471,7 @@ describe Wamp::Client::Session do
|
|
471
471
|
|
472
472
|
before(:each) do
|
473
473
|
# Check Exception
|
474
|
-
expect { session.register('test.procedure', nil, {test: 1}) }.to
|
474
|
+
expect { session.register('test.procedure', nil, {test: 1}) }.to raise_error(RuntimeError)
|
475
475
|
|
476
476
|
session.join('test')
|
477
477
|
welcome = Wamp::Client::Message::Welcome.new(1234, {})
|
@@ -482,8 +482,8 @@ describe Wamp::Client::Session do
|
|
482
482
|
it 'adds register request to queue' do
|
483
483
|
session.register('test.procedure', lambda {}, {test: 1})
|
484
484
|
|
485
|
-
expect(session.
|
486
|
-
request_id = session.
|
485
|
+
expect(session.request[:register].requests.count).to eq(1)
|
486
|
+
request_id = session.request[:register].requests.keys.first
|
487
487
|
|
488
488
|
# Check the transport messages
|
489
489
|
expect(transport.messages.count).to eq(1)
|
@@ -493,11 +493,11 @@ describe Wamp::Client::Session do
|
|
493
493
|
expect(transport.messages[0][3]).to eq('test.procedure')
|
494
494
|
|
495
495
|
# Check the request dictionary
|
496
|
-
expect(session.
|
497
|
-
expect(session.
|
496
|
+
expect(session.request[:register].requests[request_id][:p]).to eq('test.procedure')
|
497
|
+
expect(session.request[:register].requests[request_id][:o]).to eq({test: 1})
|
498
498
|
|
499
499
|
# Check the subscriptions
|
500
|
-
expect(session.
|
500
|
+
expect(session.registration.objects.count).to eq(0)
|
501
501
|
end
|
502
502
|
|
503
503
|
it 'confirms register' do
|
@@ -511,7 +511,7 @@ describe Wamp::Client::Session do
|
|
511
511
|
expect(error).to be_nil
|
512
512
|
expect(details).to eq({procedure: 'test.procedure', type: 'register', session: session})
|
513
513
|
end
|
514
|
-
request_id = session.
|
514
|
+
request_id = session.request[:register].requests.keys.first
|
515
515
|
|
516
516
|
expect(count).to eq(0)
|
517
517
|
|
@@ -522,12 +522,12 @@ describe Wamp::Client::Session do
|
|
522
522
|
expect(count).to eq(1)
|
523
523
|
|
524
524
|
# Check that the requests are empty
|
525
|
-
expect(session.
|
525
|
+
expect(session.request[:register].requests.count).to eq(0)
|
526
526
|
|
527
527
|
# Check the subscriptions
|
528
|
-
expect(session.
|
529
|
-
expect(session.
|
530
|
-
expect(session.
|
528
|
+
expect(session.registration.objects.count).to eq(1)
|
529
|
+
expect(session.registration.objects[3456].procedure).to eq('test.procedure')
|
530
|
+
expect(session.registration.objects[3456].options).to eq({test: 1})
|
531
531
|
|
532
532
|
end
|
533
533
|
|
@@ -541,7 +541,7 @@ describe Wamp::Client::Session do
|
|
541
541
|
expect(details).to eq({fail: true, procedure: 'test.procedure', type: 'register', session: session})
|
542
542
|
end
|
543
543
|
|
544
|
-
request_id = session.
|
544
|
+
request_id = session.request[:register].requests.keys.first
|
545
545
|
|
546
546
|
# Generate server response
|
547
547
|
error = Wamp::Client::Message::Error.new(Wamp::Client::Message::Types::REGISTER,
|
@@ -551,10 +551,10 @@ describe Wamp::Client::Session do
|
|
551
551
|
expect(count).to eq(1)
|
552
552
|
|
553
553
|
# Check that the requests are empty
|
554
|
-
expect(session.
|
554
|
+
expect(session.request[:register].requests.count).to eq(0)
|
555
555
|
|
556
556
|
# Check the subscriptions
|
557
|
-
expect(session.
|
557
|
+
expect(session.registration.objects.count).to eq(0)
|
558
558
|
end
|
559
559
|
|
560
560
|
end
|
@@ -565,7 +565,7 @@ describe Wamp::Client::Session do
|
|
565
565
|
@request = nil
|
566
566
|
|
567
567
|
# Check Exception
|
568
|
-
expect { session.register('test.procedure', nil, {test: 1}) }.to
|
568
|
+
expect { session.register('test.procedure', nil, {test: 1}) }.to raise_error(RuntimeError)
|
569
569
|
|
570
570
|
session.join('test')
|
571
571
|
welcome = Wamp::Client::Message::Welcome.new(1234, {})
|
@@ -576,7 +576,7 @@ describe Wamp::Client::Session do
|
|
576
576
|
@response
|
577
577
|
end
|
578
578
|
session.register('test.procedure', handler, {test: 1})
|
579
|
-
request_id = session.
|
579
|
+
request_id = session.request[:register].requests.keys.first
|
580
580
|
registered = Wamp::Client::Message::Registered.new(request_id, 3456)
|
581
581
|
transport.receive_message(registered.payload)
|
582
582
|
|
@@ -586,7 +586,7 @@ describe Wamp::Client::Session do
|
|
586
586
|
end
|
587
587
|
session.register('test.defer.procedure', defer_handler)
|
588
588
|
|
589
|
-
request_id = session.
|
589
|
+
request_id = session.request[:register].requests.keys.first
|
590
590
|
registered = Wamp::Client::Message::Registered.new(request_id, 4567)
|
591
591
|
transport.receive_message(registered.payload)
|
592
592
|
|
@@ -595,16 +595,16 @@ describe Wamp::Client::Session do
|
|
595
595
|
raise 'error'
|
596
596
|
end
|
597
597
|
session.register('test.procedure.error', handler, {test: 1})
|
598
|
-
request_id = session.
|
598
|
+
request_id = session.request[:register].requests.keys.first
|
599
599
|
registered = Wamp::Client::Message::Registered.new(request_id, 5678)
|
600
600
|
transport.receive_message(registered.payload)
|
601
601
|
|
602
602
|
# Register Call Error Response
|
603
603
|
handler = lambda do |args, kwargs, details|
|
604
|
-
raise Wamp::Client::CallError.new('test.error', ['error'])
|
604
|
+
raise Wamp::Client::Response::CallError.new('test.error', ['error'])
|
605
605
|
end
|
606
606
|
session.register('test.procedure.call.error', handler, {test: 1})
|
607
|
-
request_id = session.
|
607
|
+
request_id = session.request[:register].requests.keys.first
|
608
608
|
registered = Wamp::Client::Message::Registered.new(request_id, 6789)
|
609
609
|
transport.receive_message(registered.payload)
|
610
610
|
|
@@ -616,7 +616,7 @@ describe Wamp::Client::Session do
|
|
616
616
|
end
|
617
617
|
session.register('test.defer.interrupt.procedure', defer_handler, nil, defer_interrupt_handler)
|
618
618
|
|
619
|
-
request_id = session.
|
619
|
+
request_id = session.request[:register].requests.keys.first
|
620
620
|
registered = Wamp::Client::Message::Registered.new(request_id, 7896)
|
621
621
|
transport.receive_message(registered.payload)
|
622
622
|
|
@@ -659,7 +659,7 @@ describe Wamp::Client::Session do
|
|
659
659
|
|
660
660
|
it 'result response' do
|
661
661
|
|
662
|
-
@response = Wamp::Client::CallResult.new(['test'], {test:1})
|
662
|
+
@response = Wamp::Client::Response::CallResult.new(['test'], {test:1})
|
663
663
|
|
664
664
|
# Generate server event
|
665
665
|
invocation = Wamp::Client::Message::Invocation.new(7890, 3456, {test:1}, [2], {param: 'value'})
|
@@ -712,7 +712,7 @@ describe Wamp::Client::Session do
|
|
712
712
|
|
713
713
|
it 'return error response' do
|
714
714
|
|
715
|
-
@response = Wamp::Client::CallError.new('wamp.error.runtime', ['error'], {error: true})
|
715
|
+
@response = Wamp::Client::Response::CallError.new('wamp.error.runtime', ['error'], {error: true})
|
716
716
|
|
717
717
|
# Generate server event
|
718
718
|
invocation = Wamp::Client::Message::Invocation.new(7890, 3456, {test:1}, [2], {param: 'value'})
|
@@ -732,9 +732,9 @@ describe Wamp::Client::Session do
|
|
732
732
|
|
733
733
|
it 'defer normal response' do
|
734
734
|
|
735
|
-
@response = Wamp::Client::CallResult.new(['test'], {test:1})
|
735
|
+
@response = Wamp::Client::Response::CallResult.new(['test'], {test:1})
|
736
736
|
|
737
|
-
@defer = Wamp::Client::
|
737
|
+
@defer = Wamp::Client::Response::CallDefer.new
|
738
738
|
|
739
739
|
# Generate server event
|
740
740
|
invocation = Wamp::Client::Message::Invocation.new(7890, 4567, {test:1}, [2], {param: 'value'})
|
@@ -756,7 +756,7 @@ describe Wamp::Client::Session do
|
|
756
756
|
|
757
757
|
it 'defer error normal response' do
|
758
758
|
|
759
|
-
@defer = Wamp::Client::
|
759
|
+
@defer = Wamp::Client::Response::CallDefer.new
|
760
760
|
|
761
761
|
# Generate server event
|
762
762
|
invocation = Wamp::Client::Message::Invocation.new(7890, 4567, {test:1}, [2], {param: 'value'})
|
@@ -779,9 +779,9 @@ describe Wamp::Client::Session do
|
|
779
779
|
|
780
780
|
it 'defer error object response' do
|
781
781
|
|
782
|
-
@response = Wamp::Client::CallError.new('wamp.error.runtime', ['error'], {error: true})
|
782
|
+
@response = Wamp::Client::Response::CallError.new('wamp.error.runtime', ['error'], {error: true})
|
783
783
|
|
784
|
-
@defer = Wamp::Client::
|
784
|
+
@defer = Wamp::Client::Response::CallDefer.new
|
785
785
|
|
786
786
|
# Generate server event
|
787
787
|
invocation = Wamp::Client::Message::Invocation.new(7890, 4567, {test:1}, [2], {param: 'value'})
|
@@ -808,7 +808,7 @@ describe Wamp::Client::Session do
|
|
808
808
|
|
809
809
|
@response = nil
|
810
810
|
|
811
|
-
@defer = Wamp::Client::
|
811
|
+
@defer = Wamp::Client::Response::CallDefer.new
|
812
812
|
|
813
813
|
# Generate server event
|
814
814
|
invocation = Wamp::Client::Message::Invocation.new(7890, 7896, {test:1}, [2], {param: 'value'})
|
@@ -843,7 +843,7 @@ describe Wamp::Client::Session do
|
|
843
843
|
|
844
844
|
@response = 'custom'
|
845
845
|
|
846
|
-
@defer = Wamp::Client::
|
846
|
+
@defer = Wamp::Client::Response::CallDefer.new
|
847
847
|
|
848
848
|
# Generate server event
|
849
849
|
invocation = Wamp::Client::Message::Invocation.new(7890, 7896, {test:1}, [2], {param: 'value'})
|
@@ -877,7 +877,7 @@ describe Wamp::Client::Session do
|
|
877
877
|
|
878
878
|
before(:each) do
|
879
879
|
# Check Exception
|
880
|
-
expect { session.unregister(nil) }.to
|
880
|
+
expect { session.unregister(nil) }.to raise_error(RuntimeError)
|
881
881
|
|
882
882
|
session.join('test')
|
883
883
|
welcome = Wamp::Client::Message::Welcome.new(1234, {})
|
@@ -888,7 +888,7 @@ describe Wamp::Client::Session do
|
|
888
888
|
end
|
889
889
|
|
890
890
|
# Get the request ID
|
891
|
-
@request_id = session.
|
891
|
+
@request_id = session.request[:register].requests.keys.first
|
892
892
|
|
893
893
|
# Generate server response
|
894
894
|
registered = Wamp::Client::Message::Registered.new(@request_id, 3456)
|
@@ -900,7 +900,7 @@ describe Wamp::Client::Session do
|
|
900
900
|
it 'adds unregister request to the queue' do
|
901
901
|
session.unregister(@registration)
|
902
902
|
|
903
|
-
@request_id = session.
|
903
|
+
@request_id = session.request[:unregister].requests.keys.first
|
904
904
|
|
905
905
|
# Check the transport messages
|
906
906
|
expect(transport.messages.count).to eq(1)
|
@@ -909,10 +909,10 @@ describe Wamp::Client::Session do
|
|
909
909
|
expect(transport.messages[0][2]).to eq(@registration.id)
|
910
910
|
|
911
911
|
# Check the request dictionary
|
912
|
-
expect(session.
|
912
|
+
expect(session.request[:unregister].requests[@request_id]).not_to be_nil
|
913
913
|
|
914
914
|
# Check the subscriptions
|
915
|
-
expect(session.
|
915
|
+
expect(session.registration.objects.count).to eq(1)
|
916
916
|
|
917
917
|
end
|
918
918
|
|
@@ -927,7 +927,7 @@ describe Wamp::Client::Session do
|
|
927
927
|
expect(details).to eq({procedure: 'test.procedure', type: 'unregister', session: session})
|
928
928
|
end
|
929
929
|
|
930
|
-
@request_id = session.
|
930
|
+
@request_id = session.request[:unregister].requests.keys.first
|
931
931
|
|
932
932
|
expect(count).to eq(0)
|
933
933
|
|
@@ -936,10 +936,10 @@ describe Wamp::Client::Session do
|
|
936
936
|
transport.receive_message(unregistered.payload)
|
937
937
|
|
938
938
|
# Check the request dictionary
|
939
|
-
expect(session.
|
939
|
+
expect(session.request[:unregister].requests.count).to eq(0)
|
940
940
|
|
941
941
|
# Check the subscriptions
|
942
|
-
expect(session.
|
942
|
+
expect(session.registration.objects.count).to eq(0)
|
943
943
|
|
944
944
|
end
|
945
945
|
|
@@ -947,17 +947,17 @@ describe Wamp::Client::Session do
|
|
947
947
|
|
948
948
|
@registration.unregister
|
949
949
|
|
950
|
-
@request_id = session.
|
950
|
+
@request_id = session.request[:unregister].requests.keys.first
|
951
951
|
|
952
952
|
# Generate Server Response
|
953
953
|
unregistered = Wamp::Client::Message::Unregistered.new(@request_id)
|
954
954
|
transport.receive_message(unregistered.payload)
|
955
955
|
|
956
956
|
# Check the request dictionary
|
957
|
-
expect(session.
|
957
|
+
expect(session.request[:unregister].requests.count).to eq(0)
|
958
958
|
|
959
959
|
# Check the subscriptions
|
960
|
-
expect(session.
|
960
|
+
expect(session.registration.objects.count).to eq(0)
|
961
961
|
|
962
962
|
end
|
963
963
|
|
@@ -972,7 +972,7 @@ describe Wamp::Client::Session do
|
|
972
972
|
expect(details).to eq({fail: true, procedure:'test.procedure', type: 'unregister', session: session})
|
973
973
|
end
|
974
974
|
|
975
|
-
@request_id = session.
|
975
|
+
@request_id = session.request[:unregister].requests.keys.first
|
976
976
|
|
977
977
|
expect(count).to eq(0)
|
978
978
|
|
@@ -984,10 +984,10 @@ describe Wamp::Client::Session do
|
|
984
984
|
expect(count).to eq(1)
|
985
985
|
|
986
986
|
# Check the request dictionary
|
987
|
-
expect(session.
|
987
|
+
expect(session.request[:unregister].requests.count).to eq(0)
|
988
988
|
|
989
989
|
# Check the subscriptions
|
990
|
-
expect(session.
|
990
|
+
expect(session.registration.objects.count).to eq(1)
|
991
991
|
|
992
992
|
end
|
993
993
|
|
@@ -997,7 +997,7 @@ describe Wamp::Client::Session do
|
|
997
997
|
|
998
998
|
before(:each) do
|
999
999
|
# Check Exception
|
1000
|
-
expect { session.call('test.procedure') }.to
|
1000
|
+
expect { session.call('test.procedure') }.to raise_error(RuntimeError)
|
1001
1001
|
|
1002
1002
|
session.join('test')
|
1003
1003
|
welcome = Wamp::Client::Message::Welcome.new(1234, {})
|
@@ -1009,7 +1009,7 @@ describe Wamp::Client::Session do
|
|
1009
1009
|
it 'adds a call to the call request queue' do
|
1010
1010
|
session.call('test.procedure', nil, nil, {})
|
1011
1011
|
|
1012
|
-
@request_id = session.
|
1012
|
+
@request_id = session.request[:call].requests.keys.first
|
1013
1013
|
|
1014
1014
|
# Check the transport messages
|
1015
1015
|
expect(transport.messages.count).to eq(1)
|
@@ -1018,7 +1018,7 @@ describe Wamp::Client::Session do
|
|
1018
1018
|
expect(transport.messages[0][2]).to eq({})
|
1019
1019
|
|
1020
1020
|
# Check the request dictionary
|
1021
|
-
expect(session.
|
1021
|
+
expect(session.request[:call].requests[@request_id]).not_to be_nil
|
1022
1022
|
|
1023
1023
|
end
|
1024
1024
|
|
@@ -1031,13 +1031,13 @@ describe Wamp::Client::Session do
|
|
1031
1031
|
count += 1
|
1032
1032
|
|
1033
1033
|
expect(result).not_to be_nil
|
1034
|
-
expect(result
|
1035
|
-
expect(result
|
1034
|
+
expect(result[:args]).to eq(['test'])
|
1035
|
+
expect(result[:kwargs]).to eq({test:true})
|
1036
1036
|
expect(error).to be_nil
|
1037
1037
|
expect(details).to eq({procedure: 'test.procedure', type: 'call', session: session})
|
1038
1038
|
end
|
1039
1039
|
|
1040
|
-
@request_id = session.
|
1040
|
+
@request_id = session.request[:call].requests.keys.first
|
1041
1041
|
|
1042
1042
|
expect(count).to eq(0)
|
1043
1043
|
|
@@ -1046,7 +1046,7 @@ describe Wamp::Client::Session do
|
|
1046
1046
|
transport.receive_message(result.payload)
|
1047
1047
|
|
1048
1048
|
# Check the request dictionary
|
1049
|
-
expect(session.
|
1049
|
+
expect(session.request[:call].requests.count).to eq(0)
|
1050
1050
|
|
1051
1051
|
expect(count).to eq(1)
|
1052
1052
|
|
@@ -1063,7 +1063,7 @@ describe Wamp::Client::Session do
|
|
1063
1063
|
expect(details).to eq({fail: true, procedure: 'test.procedure', type: 'call', session: session})
|
1064
1064
|
end
|
1065
1065
|
|
1066
|
-
@request_id = session.
|
1066
|
+
@request_id = session.request[:call].requests.keys.first
|
1067
1067
|
|
1068
1068
|
expect(count).to eq(0)
|
1069
1069
|
|
@@ -1075,7 +1075,7 @@ describe Wamp::Client::Session do
|
|
1075
1075
|
expect(count).to eq(1)
|
1076
1076
|
|
1077
1077
|
# Check the request dictionary
|
1078
|
-
expect(session.
|
1078
|
+
expect(session.request[:call].requests.count).to eq(0)
|
1079
1079
|
|
1080
1080
|
end
|
1081
1081
|
|
@@ -1090,7 +1090,7 @@ describe Wamp::Client::Session do
|
|
1090
1090
|
expect(details).to eq({fail: true, procedure: 'test.procedure', type: 'call', session: session})
|
1091
1091
|
end
|
1092
1092
|
|
1093
|
-
@request_id = session.
|
1093
|
+
@request_id = session.request[:call].requests.keys.first
|
1094
1094
|
|
1095
1095
|
expect(count).to eq(0)
|
1096
1096
|
|
@@ -1111,7 +1111,7 @@ describe Wamp::Client::Session do
|
|
1111
1111
|
expect(count).to eq(1)
|
1112
1112
|
|
1113
1113
|
# Check the request dictionary
|
1114
|
-
expect(session.
|
1114
|
+
expect(session.request[:call].requests.count).to eq(0)
|
1115
1115
|
|
1116
1116
|
end
|
1117
1117
|
|
@@ -1122,7 +1122,7 @@ describe Wamp::Client::Session do
|
|
1122
1122
|
after { clock.reset }
|
1123
1123
|
|
1124
1124
|
it 'does not cancel a call if no timeout specified' do
|
1125
|
-
@defer = Wamp::Client::
|
1125
|
+
@defer = Wamp::Client::Response::ProgressiveCallDefer.new
|
1126
1126
|
|
1127
1127
|
count = 0
|
1128
1128
|
session.call('test.procedure', nil, nil) do |result, error, details|
|
@@ -1134,7 +1134,7 @@ describe Wamp::Client::Session do
|
|
1134
1134
|
end
|
1135
1135
|
|
1136
1136
|
it 'does cancel a call if a timeout is specified' do
|
1137
|
-
@defer = Wamp::Client::
|
1137
|
+
@defer = Wamp::Client::Response::ProgressiveCallDefer.new
|
1138
1138
|
|
1139
1139
|
count = 0
|
1140
1140
|
call = session.call('test.procedure', nil, nil, {timeout: 1000}) do |result, error, details|
|
@@ -1166,10 +1166,10 @@ describe Wamp::Client::Session do
|
|
1166
1166
|
|
1167
1167
|
results = []
|
1168
1168
|
session.call('test.procedure', [], {}, {}) do |result, error, details|
|
1169
|
-
results = results + result
|
1169
|
+
results = results + result[:args]
|
1170
1170
|
end
|
1171
1171
|
|
1172
|
-
@request_id = session.
|
1172
|
+
@request_id = session.request[:call].requests.keys.first
|
1173
1173
|
|
1174
1174
|
# Send results
|
1175
1175
|
result = Wamp::Client::Message::Result.new(@request_id, {progress:true}, ['test'])
|
@@ -1190,10 +1190,10 @@ describe Wamp::Client::Session do
|
|
1190
1190
|
|
1191
1191
|
results = []
|
1192
1192
|
session.call('test.procedure', [], {}, {receive_progress: true}) do |result, error, details|
|
1193
|
-
results = results + result
|
1193
|
+
results = results + result[:args]
|
1194
1194
|
end
|
1195
1195
|
|
1196
|
-
@request_id = session.
|
1196
|
+
@request_id = session.request[:call].requests.keys.first
|
1197
1197
|
|
1198
1198
|
# Send results
|
1199
1199
|
result = Wamp::Client::Message::Result.new(@request_id, {progress:true}, ['test'])
|
@@ -1223,13 +1223,13 @@ describe Wamp::Client::Session do
|
|
1223
1223
|
it 'callee result support' do
|
1224
1224
|
|
1225
1225
|
# Defer Register
|
1226
|
-
@defer = Wamp::Client::
|
1226
|
+
@defer = Wamp::Client::Response::ProgressiveCallDefer.new
|
1227
1227
|
defer_handler = lambda do |args, kwargs, details|
|
1228
1228
|
@defer
|
1229
1229
|
end
|
1230
1230
|
session.register('test.defer.procedure', defer_handler)
|
1231
1231
|
|
1232
|
-
request_id = session.
|
1232
|
+
request_id = session.request[:register].requests.keys.first
|
1233
1233
|
registered = Wamp::Client::Message::Registered.new(request_id, 4567)
|
1234
1234
|
transport.receive_message(registered.payload)
|
1235
1235
|
|
@@ -1240,14 +1240,14 @@ describe Wamp::Client::Session do
|
|
1240
1240
|
transport.receive_message(invocation.payload)
|
1241
1241
|
|
1242
1242
|
expect(transport.messages.count).to eq(0)
|
1243
|
-
expect(session.
|
1243
|
+
expect(session.registration.defers.count).to eq(1)
|
1244
1244
|
|
1245
|
-
@defer.progress(Wamp::Client::CallResult.new(['test1']))
|
1246
|
-
expect(session.
|
1247
|
-
@defer.progress(Wamp::Client::CallResult.new(['test2']))
|
1248
|
-
expect(session.
|
1249
|
-
@defer.succeed(Wamp::Client::CallResult.new(['test3']))
|
1250
|
-
expect(session.
|
1245
|
+
@defer.progress(Wamp::Client::Response::CallResult.new(['test1']))
|
1246
|
+
expect(session.registration.defers.count).to eq(1)
|
1247
|
+
@defer.progress(Wamp::Client::Response::CallResult.new(['test2']))
|
1248
|
+
expect(session.registration.defers.count).to eq(1)
|
1249
|
+
@defer.succeed(Wamp::Client::Response::CallResult.new(['test3']))
|
1250
|
+
expect(session.registration.defers.count).to eq(0)
|
1251
1251
|
|
1252
1252
|
expect(transport.messages.count).to eq(3)
|
1253
1253
|
|
@@ -1273,13 +1273,13 @@ describe Wamp::Client::Session do
|
|
1273
1273
|
it 'callee error support' do
|
1274
1274
|
|
1275
1275
|
# Defer Register
|
1276
|
-
@defer = Wamp::Client::
|
1276
|
+
@defer = Wamp::Client::Response::ProgressiveCallDefer.new
|
1277
1277
|
defer_handler = lambda do |args, kwargs, details|
|
1278
1278
|
@defer
|
1279
1279
|
end
|
1280
1280
|
session.register('test.defer.procedure', defer_handler)
|
1281
1281
|
|
1282
|
-
request_id = session.
|
1282
|
+
request_id = session.request[:register].requests.keys.first
|
1283
1283
|
registered = Wamp::Client::Message::Registered.new(request_id, 4567)
|
1284
1284
|
transport.receive_message(registered.payload)
|
1285
1285
|
|
@@ -1290,14 +1290,14 @@ describe Wamp::Client::Session do
|
|
1290
1290
|
transport.receive_message(invocation.payload)
|
1291
1291
|
|
1292
1292
|
expect(transport.messages.count).to eq(0)
|
1293
|
-
expect(session.
|
1293
|
+
expect(session.registration.defers.count).to eq(1)
|
1294
1294
|
|
1295
|
-
@defer.progress(Wamp::Client::CallResult.new(['test1']))
|
1296
|
-
expect(session.
|
1297
|
-
@defer.progress(Wamp::Client::CallResult.new(['test2']))
|
1298
|
-
expect(session.
|
1299
|
-
@defer.fail(Wamp::Client::CallError.new('test.error'))
|
1300
|
-
expect(session.
|
1295
|
+
@defer.progress(Wamp::Client::Response::CallResult.new(['test1']))
|
1296
|
+
expect(session.registration.defers.count).to eq(1)
|
1297
|
+
@defer.progress(Wamp::Client::Response::CallResult.new(['test2']))
|
1298
|
+
expect(session.registration.defers.count).to eq(1)
|
1299
|
+
@defer.fail(Wamp::Client::Response::CallError.new('test.error'))
|
1300
|
+
expect(session.registration.defers.count).to eq(0)
|
1301
1301
|
|
1302
1302
|
expect(transport.messages.count).to eq(3)
|
1303
1303
|
|
@@ -1323,13 +1323,13 @@ describe Wamp::Client::Session do
|
|
1323
1323
|
it 'callee error support' do
|
1324
1324
|
|
1325
1325
|
# Defer Register
|
1326
|
-
@defer = Wamp::Client::
|
1326
|
+
@defer = Wamp::Client::Response::ProgressiveCallDefer.new
|
1327
1327
|
defer_handler = lambda do |args, kwargs, details|
|
1328
1328
|
@defer
|
1329
1329
|
end
|
1330
1330
|
session.register('test.defer.procedure', defer_handler)
|
1331
1331
|
|
1332
|
-
request_id = session.
|
1332
|
+
request_id = session.request[:register].requests.keys.first
|
1333
1333
|
registered = Wamp::Client::Message::Registered.new(request_id, 4567)
|
1334
1334
|
transport.receive_message(registered.payload)
|
1335
1335
|
|
@@ -1340,14 +1340,14 @@ describe Wamp::Client::Session do
|
|
1340
1340
|
transport.receive_message(invocation.payload)
|
1341
1341
|
|
1342
1342
|
expect(transport.messages.count).to eq(0)
|
1343
|
-
expect(session.
|
1343
|
+
expect(session.registration.defers.count).to eq(1)
|
1344
1344
|
|
1345
|
-
@defer.progress(Wamp::Client::CallResult.new(['test1']))
|
1346
|
-
expect(session.
|
1347
|
-
@defer.progress(Wamp::Client::CallResult.new(['test2']))
|
1348
|
-
expect(session.
|
1349
|
-
@defer.fail(Wamp::Client::CallError.new('test.error'))
|
1350
|
-
expect(session.
|
1345
|
+
@defer.progress(Wamp::Client::Response::CallResult.new(['test1']))
|
1346
|
+
expect(session.registration.defers.count).to eq(1)
|
1347
|
+
@defer.progress(Wamp::Client::Response::CallResult.new(['test2']))
|
1348
|
+
expect(session.registration.defers.count).to eq(1)
|
1349
|
+
@defer.fail(Wamp::Client::Response::CallError.new('test.error'))
|
1350
|
+
expect(session.registration.defers.count).to eq(0)
|
1351
1351
|
|
1352
1352
|
expect(transport.messages.count).to eq(3)
|
1353
1353
|
|
@@ -1381,7 +1381,7 @@ describe Wamp::Client::Session do
|
|
1381
1381
|
session.join('test')
|
1382
1382
|
transport.messages = []
|
1383
1383
|
|
1384
|
-
session.
|
1384
|
+
session.on :challenge do |authmethod, extra|
|
1385
1385
|
expect(authmethod).to eq('wampcra')
|
1386
1386
|
Wamp::Client::Auth::Cra.sign(secret, extra[:challenge])
|
1387
1387
|
end
|