wamp_client 0.0.1

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.
@@ -0,0 +1,1283 @@
1
+ require 'wamp_client/check'
2
+
3
+ # !!!!THIS FILE IS AUTOGENERATED. DO NOT HAND EDIT!!!!
4
+
5
+ module WampClient
6
+ module Message
7
+
8
+ module Types
9
+ HELLO = 1
10
+ WELCOME = 2
11
+ ABORT = 3
12
+ CHALLENGE = 4
13
+ AUTHENTICATE = 5
14
+ GOODBYE = 6
15
+ ERROR = 8
16
+ PUBLISH = 16
17
+ PUBLISHED = 17
18
+ SUBSCRIBE = 32
19
+ SUBSCRIBED = 33
20
+ UNSUBSCRIBE = 34
21
+ UNSUBSCRIBED = 35
22
+ EVENT = 36
23
+ CALL = 48
24
+ CANCEL = 49
25
+ RESULT = 50
26
+ REGISTER = 64
27
+ REGISTERED = 65
28
+ UNREGISTER = 66
29
+ UNREGISTERED = 67
30
+ INVOCATION = 68
31
+ INTERRUPT = 69
32
+ YIELD = 70
33
+ end
34
+
35
+ class Base
36
+ include WampClient::Check
37
+
38
+ def payload
39
+ []
40
+ end
41
+
42
+ # @param params [Array]
43
+ def self.parse(params)
44
+ object = nil
45
+ if params[0] == Types::HELLO
46
+ object = WampClient::Message::Hello.parse(params)
47
+ elsif params[0] == Types::WELCOME
48
+ object = WampClient::Message::Welcome.parse(params)
49
+ elsif params[0] == Types::ABORT
50
+ object = WampClient::Message::Abort.parse(params)
51
+ elsif params[0] == Types::CHALLENGE
52
+ object = WampClient::Message::Challenge.parse(params)
53
+ elsif params[0] == Types::AUTHENTICATE
54
+ object = WampClient::Message::Authenticate.parse(params)
55
+ elsif params[0] == Types::GOODBYE
56
+ object = WampClient::Message::Goodbye.parse(params)
57
+ elsif params[0] == Types::ERROR
58
+ object = WampClient::Message::Error.parse(params)
59
+ elsif params[0] == Types::PUBLISH
60
+ object = WampClient::Message::Publish.parse(params)
61
+ elsif params[0] == Types::PUBLISHED
62
+ object = WampClient::Message::Published.parse(params)
63
+ elsif params[0] == Types::SUBSCRIBE
64
+ object = WampClient::Message::Subscribe.parse(params)
65
+ elsif params[0] == Types::SUBSCRIBED
66
+ object = WampClient::Message::Subscribed.parse(params)
67
+ elsif params[0] == Types::UNSUBSCRIBE
68
+ object = WampClient::Message::Unsubscribe.parse(params)
69
+ elsif params[0] == Types::UNSUBSCRIBED
70
+ object = WampClient::Message::Unsubscribed.parse(params)
71
+ elsif params[0] == Types::EVENT
72
+ object = WampClient::Message::Event.parse(params)
73
+ elsif params[0] == Types::CALL
74
+ object = WampClient::Message::Call.parse(params)
75
+ elsif params[0] == Types::CANCEL
76
+ object = WampClient::Message::Cancel.parse(params)
77
+ elsif params[0] == Types::RESULT
78
+ object = WampClient::Message::Result.parse(params)
79
+ elsif params[0] == Types::REGISTER
80
+ object = WampClient::Message::Register.parse(params)
81
+ elsif params[0] == Types::REGISTERED
82
+ object = WampClient::Message::Registered.parse(params)
83
+ elsif params[0] == Types::UNREGISTER
84
+ object = WampClient::Message::Unregister.parse(params)
85
+ elsif params[0] == Types::UNREGISTERED
86
+ object = WampClient::Message::Unregistered.parse(params)
87
+ elsif params[0] == Types::INVOCATION
88
+ object = WampClient::Message::Invocation.parse(params)
89
+ elsif params[0] == Types::INTERRUPT
90
+ object = WampClient::Message::Interrupt.parse(params)
91
+ elsif params[0] == Types::YIELD
92
+ object = WampClient::Message::Yield.parse(params)
93
+ end
94
+
95
+ object
96
+ end
97
+
98
+ end
99
+
100
+ # Hello
101
+ # Sent by a Client to initiate opening of a WAMP session to a Router attaching to a Realm.
102
+ # Formats:
103
+ # [HELLO, Realm|uri, Details|dict]
104
+ class Hello < Base
105
+ attr_accessor :realm, :details
106
+
107
+ def initialize(realm, details)
108
+
109
+ self.class.check_uri('realm', realm)
110
+ self.class.check_dict('details', details)
111
+
112
+ self.realm = realm
113
+ self.details = details
114
+
115
+ end
116
+
117
+ def self.type
118
+ Types::HELLO
119
+ end
120
+
121
+ def self.parse(params)
122
+
123
+ self.check_gte('params list', 3, params.count)
124
+ self.check_equal('message type', self.type, params[0])
125
+
126
+ params.shift
127
+ self.new(*params)
128
+
129
+ end
130
+
131
+ def payload
132
+ payload = [self.class.type]
133
+ payload.push(self.realm)
134
+ payload.push(self.details)
135
+
136
+ payload
137
+ end
138
+
139
+ def to_s
140
+ 'HELLO > ' + self.payload.to_s
141
+ end
142
+
143
+ end
144
+
145
+ # Welcome
146
+ # Sent by a Router to accept a Client. The WAMP session is now open.
147
+ # Formats:
148
+ # [WELCOME, Session|id, Details|dict]
149
+ class Welcome < Base
150
+ attr_accessor :session, :details
151
+
152
+ def initialize(session, details)
153
+
154
+ self.class.check_id('session', session)
155
+ self.class.check_dict('details', details)
156
+
157
+ self.session = session
158
+ self.details = details
159
+
160
+ end
161
+
162
+ def self.type
163
+ Types::WELCOME
164
+ end
165
+
166
+ def self.parse(params)
167
+
168
+ self.check_gte('params list', 3, params.count)
169
+ self.check_equal('message type', self.type, params[0])
170
+
171
+ params.shift
172
+ self.new(*params)
173
+
174
+ end
175
+
176
+ def payload
177
+ payload = [self.class.type]
178
+ payload.push(self.session)
179
+ payload.push(self.details)
180
+
181
+ payload
182
+ end
183
+
184
+ def to_s
185
+ 'WELCOME > ' + self.payload.to_s
186
+ end
187
+
188
+ end
189
+
190
+ # Abort
191
+ # Sent by a Peer*to abort the opening of a WAMP session. No response is expected.
192
+ # Formats:
193
+ # [ABORT, Details|dict, Reason|uri]
194
+ class Abort < Base
195
+ attr_accessor :details, :reason
196
+
197
+ def initialize(details, reason)
198
+
199
+ self.class.check_dict('details', details)
200
+ self.class.check_uri('reason', reason)
201
+
202
+ self.details = details
203
+ self.reason = reason
204
+
205
+ end
206
+
207
+ def self.type
208
+ Types::ABORT
209
+ end
210
+
211
+ def self.parse(params)
212
+
213
+ self.check_gte('params list', 3, params.count)
214
+ self.check_equal('message type', self.type, params[0])
215
+
216
+ params.shift
217
+ self.new(*params)
218
+
219
+ end
220
+
221
+ def payload
222
+ payload = [self.class.type]
223
+ payload.push(self.details)
224
+ payload.push(self.reason)
225
+
226
+ payload
227
+ end
228
+
229
+ def to_s
230
+ 'ABORT > ' + self.payload.to_s
231
+ end
232
+
233
+ end
234
+
235
+ # Goodbye
236
+ # Sent by a Peer to close a previously opened WAMP session. Must be echo'ed by the receiving Peer.
237
+ # Formats:
238
+ # [GOODBYE, Details|dict, Reason|uri]
239
+ class Goodbye < Base
240
+ attr_accessor :details, :reason
241
+
242
+ def initialize(details, reason)
243
+
244
+ self.class.check_dict('details', details)
245
+ self.class.check_uri('reason', reason)
246
+
247
+ self.details = details
248
+ self.reason = reason
249
+
250
+ end
251
+
252
+ def self.type
253
+ Types::GOODBYE
254
+ end
255
+
256
+ def self.parse(params)
257
+
258
+ self.check_gte('params list', 3, params.count)
259
+ self.check_equal('message type', self.type, params[0])
260
+
261
+ params.shift
262
+ self.new(*params)
263
+
264
+ end
265
+
266
+ def payload
267
+ payload = [self.class.type]
268
+ payload.push(self.details)
269
+ payload.push(self.reason)
270
+
271
+ payload
272
+ end
273
+
274
+ def to_s
275
+ 'GOODBYE > ' + self.payload.to_s
276
+ end
277
+
278
+ end
279
+
280
+ # Error
281
+ # Error reply sent by a Peer as an error response to different kinds of requests.
282
+ # Formats:
283
+ # [ERROR, REQUEST.Type|int, REQUEST.Request|id, Details|dict, Error|uri]
284
+ # [ERROR, REQUEST.Type|int, REQUEST.Request|id, Details|dict, Error|uri, Arguments|list]
285
+ # [ERROR, REQUEST.Type|int, REQUEST.Request|id, Details|dict, Error|uri, Arguments|list, ArgumentsKw|dict]
286
+ class Error < Base
287
+ attr_accessor :request_type, :request_request, :details, :error, :arguments, :argumentskw
288
+
289
+ def initialize(request_type, request_request, details, error, arguments=nil, argumentskw=nil)
290
+
291
+ self.class.check_int('request_type', request_type)
292
+ self.class.check_id('request_request', request_request)
293
+ self.class.check_dict('details', details)
294
+ self.class.check_uri('error', error)
295
+ self.class.check_list('arguments', arguments, true)
296
+ self.class.check_dict('argumentskw', argumentskw, true)
297
+
298
+ self.request_type = request_type
299
+ self.request_request = request_request
300
+ self.details = details
301
+ self.error = error
302
+ self.arguments = arguments
303
+ self.argumentskw = argumentskw
304
+
305
+ end
306
+
307
+ def self.type
308
+ Types::ERROR
309
+ end
310
+
311
+ def self.parse(params)
312
+
313
+ self.check_gte('params list', 5, params.count)
314
+ self.check_equal('message type', self.type, params[0])
315
+
316
+ params.shift
317
+ self.new(*params)
318
+
319
+ end
320
+
321
+ def payload
322
+ payload = [self.class.type]
323
+ payload.push(self.request_type)
324
+ payload.push(self.request_request)
325
+ payload.push(self.details)
326
+ payload.push(self.error)
327
+
328
+ return payload if (self.arguments.nil? or self.arguments.empty?)
329
+ payload.push(self.arguments)
330
+
331
+ return payload if (self.argumentskw.nil? or self.argumentskw.empty?)
332
+ payload.push(self.argumentskw)
333
+
334
+ payload
335
+ end
336
+
337
+ def to_s
338
+ 'ERROR > ' + self.payload.to_s
339
+ end
340
+
341
+ end
342
+
343
+ # Publish
344
+ # Sent by a Publisher to a Broker to publish an event.
345
+ # Formats:
346
+ # [PUBLISH, Request|id, Options|dict, Topic|uri]
347
+ # [PUBLISH, Request|id, Options|dict, Topic|uri, Arguments|list]
348
+ # [PUBLISH, Request|id, Options|dict, Topic|uri, Arguments|list, ArgumentsKw|dict]
349
+ class Publish < Base
350
+ attr_accessor :request, :options, :topic, :arguments, :argumentskw
351
+
352
+ def initialize(request, options, topic, arguments=nil, argumentskw=nil)
353
+
354
+ self.class.check_id('request', request)
355
+ self.class.check_dict('options', options)
356
+ self.class.check_uri('topic', topic)
357
+ self.class.check_list('arguments', arguments, true)
358
+ self.class.check_dict('argumentskw', argumentskw, true)
359
+
360
+ self.request = request
361
+ self.options = options
362
+ self.topic = topic
363
+ self.arguments = arguments
364
+ self.argumentskw = argumentskw
365
+
366
+ end
367
+
368
+ def self.type
369
+ Types::PUBLISH
370
+ end
371
+
372
+ def self.parse(params)
373
+
374
+ self.check_gte('params list', 4, params.count)
375
+ self.check_equal('message type', self.type, params[0])
376
+
377
+ params.shift
378
+ self.new(*params)
379
+
380
+ end
381
+
382
+ def payload
383
+ payload = [self.class.type]
384
+ payload.push(self.request)
385
+ payload.push(self.options)
386
+ payload.push(self.topic)
387
+
388
+ return payload if (self.arguments.nil? or self.arguments.empty?)
389
+ payload.push(self.arguments)
390
+
391
+ return payload if (self.argumentskw.nil? or self.argumentskw.empty?)
392
+ payload.push(self.argumentskw)
393
+
394
+ payload
395
+ end
396
+
397
+ def to_s
398
+ 'PUBLISH > ' + self.payload.to_s
399
+ end
400
+
401
+ end
402
+
403
+ # Published
404
+ # Acknowledge sent by a Broker to a Publisher for acknowledged publications.
405
+ # Formats:
406
+ # [PUBLISHED, PUBLISH.Request|id, Publication|id]
407
+ class Published < Base
408
+ attr_accessor :publish_request, :publication
409
+
410
+ def initialize(publish_request, publication)
411
+
412
+ self.class.check_id('publish_request', publish_request)
413
+ self.class.check_id('publication', publication)
414
+
415
+ self.publish_request = publish_request
416
+ self.publication = publication
417
+
418
+ end
419
+
420
+ def self.type
421
+ Types::PUBLISHED
422
+ end
423
+
424
+ def self.parse(params)
425
+
426
+ self.check_gte('params list', 3, params.count)
427
+ self.check_equal('message type', self.type, params[0])
428
+
429
+ params.shift
430
+ self.new(*params)
431
+
432
+ end
433
+
434
+ def payload
435
+ payload = [self.class.type]
436
+ payload.push(self.publish_request)
437
+ payload.push(self.publication)
438
+
439
+ payload
440
+ end
441
+
442
+ def to_s
443
+ 'PUBLISHED > ' + self.payload.to_s
444
+ end
445
+
446
+ end
447
+
448
+ # Subscribe
449
+ # Subscribe request sent by a Subscriber to a Broker to subscribe to a topic.
450
+ # Formats:
451
+ # [SUBSCRIBE, Request|id, Options|dict, Topic|uri]
452
+ class Subscribe < Base
453
+ attr_accessor :request, :options, :topic
454
+
455
+ def initialize(request, options, topic)
456
+
457
+ self.class.check_id('request', request)
458
+ self.class.check_dict('options', options)
459
+ self.class.check_uri('topic', topic)
460
+
461
+ self.request = request
462
+ self.options = options
463
+ self.topic = topic
464
+
465
+ end
466
+
467
+ def self.type
468
+ Types::SUBSCRIBE
469
+ end
470
+
471
+ def self.parse(params)
472
+
473
+ self.check_gte('params list', 4, params.count)
474
+ self.check_equal('message type', self.type, params[0])
475
+
476
+ params.shift
477
+ self.new(*params)
478
+
479
+ end
480
+
481
+ def payload
482
+ payload = [self.class.type]
483
+ payload.push(self.request)
484
+ payload.push(self.options)
485
+ payload.push(self.topic)
486
+
487
+ payload
488
+ end
489
+
490
+ def to_s
491
+ 'SUBSCRIBE > ' + self.payload.to_s
492
+ end
493
+
494
+ end
495
+
496
+ # Subscribed
497
+ # Acknowledge sent by a Broker to a Subscriber to acknowledge a subscription.
498
+ # Formats:
499
+ # [SUBSCRIBED, SUBSCRIBE.Request|id, Subscription|id]
500
+ class Subscribed < Base
501
+ attr_accessor :subscribe_request, :subscription
502
+
503
+ def initialize(subscribe_request, subscription)
504
+
505
+ self.class.check_id('subscribe_request', subscribe_request)
506
+ self.class.check_id('subscription', subscription)
507
+
508
+ self.subscribe_request = subscribe_request
509
+ self.subscription = subscription
510
+
511
+ end
512
+
513
+ def self.type
514
+ Types::SUBSCRIBED
515
+ end
516
+
517
+ def self.parse(params)
518
+
519
+ self.check_gte('params list', 3, params.count)
520
+ self.check_equal('message type', self.type, params[0])
521
+
522
+ params.shift
523
+ self.new(*params)
524
+
525
+ end
526
+
527
+ def payload
528
+ payload = [self.class.type]
529
+ payload.push(self.subscribe_request)
530
+ payload.push(self.subscription)
531
+
532
+ payload
533
+ end
534
+
535
+ def to_s
536
+ 'SUBSCRIBED > ' + self.payload.to_s
537
+ end
538
+
539
+ end
540
+
541
+ # Unsubscribe
542
+ # Unsubscribe request sent by a Subscriber to a Broker to unsubscribe a subscription.
543
+ # Formats:
544
+ # [UNSUBSCRIBE, Request|id, SUBSCRIBED.Subscription|id]
545
+ class Unsubscribe < Base
546
+ attr_accessor :request, :subscribed_subscription
547
+
548
+ def initialize(request, subscribed_subscription)
549
+
550
+ self.class.check_id('request', request)
551
+ self.class.check_id('subscribed_subscription', subscribed_subscription)
552
+
553
+ self.request = request
554
+ self.subscribed_subscription = subscribed_subscription
555
+
556
+ end
557
+
558
+ def self.type
559
+ Types::UNSUBSCRIBE
560
+ end
561
+
562
+ def self.parse(params)
563
+
564
+ self.check_gte('params list', 3, params.count)
565
+ self.check_equal('message type', self.type, params[0])
566
+
567
+ params.shift
568
+ self.new(*params)
569
+
570
+ end
571
+
572
+ def payload
573
+ payload = [self.class.type]
574
+ payload.push(self.request)
575
+ payload.push(self.subscribed_subscription)
576
+
577
+ payload
578
+ end
579
+
580
+ def to_s
581
+ 'UNSUBSCRIBE > ' + self.payload.to_s
582
+ end
583
+
584
+ end
585
+
586
+ # Unsubscribed
587
+ # Acknowledge sent by a Broker to a Subscriber to acknowledge unsubscription.
588
+ # Formats:
589
+ # [UNSUBSCRIBED, UNSUBSCRIBE.Request|id]
590
+ class Unsubscribed < Base
591
+ attr_accessor :unsubscribe_request
592
+
593
+ def initialize(unsubscribe_request)
594
+
595
+ self.class.check_id('unsubscribe_request', unsubscribe_request)
596
+
597
+ self.unsubscribe_request = unsubscribe_request
598
+
599
+ end
600
+
601
+ def self.type
602
+ Types::UNSUBSCRIBED
603
+ end
604
+
605
+ def self.parse(params)
606
+
607
+ self.check_gte('params list', 2, params.count)
608
+ self.check_equal('message type', self.type, params[0])
609
+
610
+ params.shift
611
+ self.new(*params)
612
+
613
+ end
614
+
615
+ def payload
616
+ payload = [self.class.type]
617
+ payload.push(self.unsubscribe_request)
618
+
619
+ payload
620
+ end
621
+
622
+ def to_s
623
+ 'UNSUBSCRIBED > ' + self.payload.to_s
624
+ end
625
+
626
+ end
627
+
628
+ # Event
629
+ # Event dispatched by Broker to Subscribers for subscriptions the event was matching.
630
+ # Formats:
631
+ # [EVENT, SUBSCRIBED.Subscription|id, PUBLISHED.Publication|id, Details|dict]
632
+ # [EVENT, SUBSCRIBED.Subscription|id, PUBLISHED.Publication|id, Details|dict, PUBLISH.Arguments|list]
633
+ # [EVENT, SUBSCRIBED.Subscription|id, PUBLISHED.Publication|id, Details|dict, PUBLISH.Arguments|list, PUBLISH.ArgumentsKw|dict]
634
+ class Event < Base
635
+ attr_accessor :subscribed_subscription, :published_publication, :details, :publish_arguments, :publish_argumentskw
636
+
637
+ def initialize(subscribed_subscription, published_publication, details, publish_arguments=nil, publish_argumentskw=nil)
638
+
639
+ self.class.check_id('subscribed_subscription', subscribed_subscription)
640
+ self.class.check_id('published_publication', published_publication)
641
+ self.class.check_dict('details', details)
642
+ self.class.check_list('publish_arguments', publish_arguments, true)
643
+ self.class.check_dict('publish_argumentskw', publish_argumentskw, true)
644
+
645
+ self.subscribed_subscription = subscribed_subscription
646
+ self.published_publication = published_publication
647
+ self.details = details
648
+ self.publish_arguments = publish_arguments
649
+ self.publish_argumentskw = publish_argumentskw
650
+
651
+ end
652
+
653
+ def self.type
654
+ Types::EVENT
655
+ end
656
+
657
+ def self.parse(params)
658
+
659
+ self.check_gte('params list', 4, params.count)
660
+ self.check_equal('message type', self.type, params[0])
661
+
662
+ params.shift
663
+ self.new(*params)
664
+
665
+ end
666
+
667
+ def payload
668
+ payload = [self.class.type]
669
+ payload.push(self.subscribed_subscription)
670
+ payload.push(self.published_publication)
671
+ payload.push(self.details)
672
+
673
+ return payload if (self.publish_arguments.nil? or self.publish_arguments.empty?)
674
+ payload.push(self.publish_arguments)
675
+
676
+ return payload if (self.publish_argumentskw.nil? or self.publish_argumentskw.empty?)
677
+ payload.push(self.publish_argumentskw)
678
+
679
+ payload
680
+ end
681
+
682
+ def to_s
683
+ 'EVENT > ' + self.payload.to_s
684
+ end
685
+
686
+ end
687
+
688
+ # Call
689
+ # Call as originally issued by the _Caller_ to the _Dealer_.
690
+ # Formats:
691
+ # [CALL, Request|id, Options|dict, Procedure|uri]
692
+ # [CALL, Request|id, Options|dict, Procedure|uri, Arguments|list]
693
+ # [CALL, Request|id, Options|dict, Procedure|uri, Arguments|list, ArgumentsKw|dict]
694
+ class Call < Base
695
+ attr_accessor :request, :options, :procedure, :arguments, :argumentskw
696
+
697
+ def initialize(request, options, procedure, arguments=nil, argumentskw=nil)
698
+
699
+ self.class.check_id('request', request)
700
+ self.class.check_dict('options', options)
701
+ self.class.check_uri('procedure', procedure)
702
+ self.class.check_list('arguments', arguments, true)
703
+ self.class.check_dict('argumentskw', argumentskw, true)
704
+
705
+ self.request = request
706
+ self.options = options
707
+ self.procedure = procedure
708
+ self.arguments = arguments
709
+ self.argumentskw = argumentskw
710
+
711
+ end
712
+
713
+ def self.type
714
+ Types::CALL
715
+ end
716
+
717
+ def self.parse(params)
718
+
719
+ self.check_gte('params list', 4, params.count)
720
+ self.check_equal('message type', self.type, params[0])
721
+
722
+ params.shift
723
+ self.new(*params)
724
+
725
+ end
726
+
727
+ def payload
728
+ payload = [self.class.type]
729
+ payload.push(self.request)
730
+ payload.push(self.options)
731
+ payload.push(self.procedure)
732
+
733
+ return payload if (self.arguments.nil? or self.arguments.empty?)
734
+ payload.push(self.arguments)
735
+
736
+ return payload if (self.argumentskw.nil? or self.argumentskw.empty?)
737
+ payload.push(self.argumentskw)
738
+
739
+ payload
740
+ end
741
+
742
+ def to_s
743
+ 'CALL > ' + self.payload.to_s
744
+ end
745
+
746
+ end
747
+
748
+ # Result
749
+ # Result of a call as returned by _Dealer_ to _Caller_.
750
+ # Formats:
751
+ # [RESULT, CALL.Request|id, Details|dict]
752
+ # [RESULT, CALL.Request|id, Details|dict, YIELD.Arguments|list]
753
+ # [RESULT, CALL.Request|id, Details|dict, YIELD.Arguments|list, YIELD.ArgumentsKw|dict]
754
+ class Result < Base
755
+ attr_accessor :call_request, :details, :yield_arguments, :yield_argumentskw
756
+
757
+ def initialize(call_request, details, yield_arguments=nil, yield_argumentskw=nil)
758
+
759
+ self.class.check_id('call_request', call_request)
760
+ self.class.check_dict('details', details)
761
+ self.class.check_list('yield_arguments', yield_arguments, true)
762
+ self.class.check_dict('yield_argumentskw', yield_argumentskw, true)
763
+
764
+ self.call_request = call_request
765
+ self.details = details
766
+ self.yield_arguments = yield_arguments
767
+ self.yield_argumentskw = yield_argumentskw
768
+
769
+ end
770
+
771
+ def self.type
772
+ Types::RESULT
773
+ end
774
+
775
+ def self.parse(params)
776
+
777
+ self.check_gte('params list', 3, params.count)
778
+ self.check_equal('message type', self.type, params[0])
779
+
780
+ params.shift
781
+ self.new(*params)
782
+
783
+ end
784
+
785
+ def payload
786
+ payload = [self.class.type]
787
+ payload.push(self.call_request)
788
+ payload.push(self.details)
789
+
790
+ return payload if (self.yield_arguments.nil? or self.yield_arguments.empty?)
791
+ payload.push(self.yield_arguments)
792
+
793
+ return payload if (self.yield_argumentskw.nil? or self.yield_argumentskw.empty?)
794
+ payload.push(self.yield_argumentskw)
795
+
796
+ payload
797
+ end
798
+
799
+ def to_s
800
+ 'RESULT > ' + self.payload.to_s
801
+ end
802
+
803
+ end
804
+
805
+ # Register
806
+ # A _Callees_ request to register an endpoint at a _Dealer_.
807
+ # Formats:
808
+ # [REGISTER, Request|id, Options|dict, Procedure|uri]
809
+ class Register < Base
810
+ attr_accessor :request, :options, :procedure
811
+
812
+ def initialize(request, options, procedure)
813
+
814
+ self.class.check_id('request', request)
815
+ self.class.check_dict('options', options)
816
+ self.class.check_uri('procedure', procedure)
817
+
818
+ self.request = request
819
+ self.options = options
820
+ self.procedure = procedure
821
+
822
+ end
823
+
824
+ def self.type
825
+ Types::REGISTER
826
+ end
827
+
828
+ def self.parse(params)
829
+
830
+ self.check_gte('params list', 4, params.count)
831
+ self.check_equal('message type', self.type, params[0])
832
+
833
+ params.shift
834
+ self.new(*params)
835
+
836
+ end
837
+
838
+ def payload
839
+ payload = [self.class.type]
840
+ payload.push(self.request)
841
+ payload.push(self.options)
842
+ payload.push(self.procedure)
843
+
844
+ payload
845
+ end
846
+
847
+ def to_s
848
+ 'REGISTER > ' + self.payload.to_s
849
+ end
850
+
851
+ end
852
+
853
+ # Registered
854
+ # Acknowledge sent by a _Dealer_ to a _Callee_ for successful registration.
855
+ # Formats:
856
+ # [REGISTERED, REGISTER.Request|id, Registration|id]
857
+ class Registered < Base
858
+ attr_accessor :register_request, :registration
859
+
860
+ def initialize(register_request, registration)
861
+
862
+ self.class.check_id('register_request', register_request)
863
+ self.class.check_id('registration', registration)
864
+
865
+ self.register_request = register_request
866
+ self.registration = registration
867
+
868
+ end
869
+
870
+ def self.type
871
+ Types::REGISTERED
872
+ end
873
+
874
+ def self.parse(params)
875
+
876
+ self.check_gte('params list', 3, params.count)
877
+ self.check_equal('message type', self.type, params[0])
878
+
879
+ params.shift
880
+ self.new(*params)
881
+
882
+ end
883
+
884
+ def payload
885
+ payload = [self.class.type]
886
+ payload.push(self.register_request)
887
+ payload.push(self.registration)
888
+
889
+ payload
890
+ end
891
+
892
+ def to_s
893
+ 'REGISTERED > ' + self.payload.to_s
894
+ end
895
+
896
+ end
897
+
898
+ # Unregister
899
+ # A _Callees_ request to unregister a previously established registration.
900
+ # Formats:
901
+ # [UNREGISTER, Request|id, REGISTERED.Registration|id]
902
+ class Unregister < Base
903
+ attr_accessor :request, :registered_registration
904
+
905
+ def initialize(request, registered_registration)
906
+
907
+ self.class.check_id('request', request)
908
+ self.class.check_id('registered_registration', registered_registration)
909
+
910
+ self.request = request
911
+ self.registered_registration = registered_registration
912
+
913
+ end
914
+
915
+ def self.type
916
+ Types::UNREGISTER
917
+ end
918
+
919
+ def self.parse(params)
920
+
921
+ self.check_gte('params list', 3, params.count)
922
+ self.check_equal('message type', self.type, params[0])
923
+
924
+ params.shift
925
+ self.new(*params)
926
+
927
+ end
928
+
929
+ def payload
930
+ payload = [self.class.type]
931
+ payload.push(self.request)
932
+ payload.push(self.registered_registration)
933
+
934
+ payload
935
+ end
936
+
937
+ def to_s
938
+ 'UNREGISTER > ' + self.payload.to_s
939
+ end
940
+
941
+ end
942
+
943
+ # Unregistered
944
+ # Acknowledge sent by a _Dealer_ to a _Callee_ for successful unregistration.
945
+ # Formats:
946
+ # [UNREGISTERED, UNREGISTER.Request|id]
947
+ class Unregistered < Base
948
+ attr_accessor :unregister_request
949
+
950
+ def initialize(unregister_request)
951
+
952
+ self.class.check_id('unregister_request', unregister_request)
953
+
954
+ self.unregister_request = unregister_request
955
+
956
+ end
957
+
958
+ def self.type
959
+ Types::UNREGISTERED
960
+ end
961
+
962
+ def self.parse(params)
963
+
964
+ self.check_gte('params list', 2, params.count)
965
+ self.check_equal('message type', self.type, params[0])
966
+
967
+ params.shift
968
+ self.new(*params)
969
+
970
+ end
971
+
972
+ def payload
973
+ payload = [self.class.type]
974
+ payload.push(self.unregister_request)
975
+
976
+ payload
977
+ end
978
+
979
+ def to_s
980
+ 'UNREGISTERED > ' + self.payload.to_s
981
+ end
982
+
983
+ end
984
+
985
+ # Invocation
986
+ # Actual invocation of an endpoint sent by _Dealer_ to a _Callee_.
987
+ # Formats:
988
+ # [INVOCATION, Request|id, REGISTERED.Registration|id, Details|dict]
989
+ # [INVOCATION, Request|id, REGISTERED.Registration|id, Details|dict, CALL.Arguments|list]
990
+ # [INVOCATION, Request|id, REGISTERED.Registration|id, Details|dict, CALL.Arguments|list, CALL.ArgumentsKw|dict]
991
+ class Invocation < Base
992
+ attr_accessor :request, :registered_registration, :details, :call_arguments, :call_argumentskw
993
+
994
+ def initialize(request, registered_registration, details, call_arguments=nil, call_argumentskw=nil)
995
+
996
+ self.class.check_id('request', request)
997
+ self.class.check_id('registered_registration', registered_registration)
998
+ self.class.check_dict('details', details)
999
+ self.class.check_list('call_arguments', call_arguments, true)
1000
+ self.class.check_dict('call_argumentskw', call_argumentskw, true)
1001
+
1002
+ self.request = request
1003
+ self.registered_registration = registered_registration
1004
+ self.details = details
1005
+ self.call_arguments = call_arguments
1006
+ self.call_argumentskw = call_argumentskw
1007
+
1008
+ end
1009
+
1010
+ def self.type
1011
+ Types::INVOCATION
1012
+ end
1013
+
1014
+ def self.parse(params)
1015
+
1016
+ self.check_gte('params list', 4, params.count)
1017
+ self.check_equal('message type', self.type, params[0])
1018
+
1019
+ params.shift
1020
+ self.new(*params)
1021
+
1022
+ end
1023
+
1024
+ def payload
1025
+ payload = [self.class.type]
1026
+ payload.push(self.request)
1027
+ payload.push(self.registered_registration)
1028
+ payload.push(self.details)
1029
+
1030
+ return payload if (self.call_arguments.nil? or self.call_arguments.empty?)
1031
+ payload.push(self.call_arguments)
1032
+
1033
+ return payload if (self.call_argumentskw.nil? or self.call_argumentskw.empty?)
1034
+ payload.push(self.call_argumentskw)
1035
+
1036
+ payload
1037
+ end
1038
+
1039
+ def to_s
1040
+ 'INVOCATION > ' + self.payload.to_s
1041
+ end
1042
+
1043
+ end
1044
+
1045
+ # Yield
1046
+ # Actual yield from an endpoint sent by a _Callee_ to _Dealer_.
1047
+ # Formats:
1048
+ # [YIELD, INVOCATION.Request|id, Options|dict]
1049
+ # [YIELD, INVOCATION.Request|id, Options|dict, Arguments|list]
1050
+ # [YIELD, INVOCATION.Request|id, Options|dict, Arguments|list, ArgumentsKw|dict]
1051
+ class Yield < Base
1052
+ attr_accessor :invocation_request, :options, :arguments, :argumentskw
1053
+
1054
+ def initialize(invocation_request, options, arguments=nil, argumentskw=nil)
1055
+
1056
+ self.class.check_id('invocation_request', invocation_request)
1057
+ self.class.check_dict('options', options)
1058
+ self.class.check_list('arguments', arguments, true)
1059
+ self.class.check_dict('argumentskw', argumentskw, true)
1060
+
1061
+ self.invocation_request = invocation_request
1062
+ self.options = options
1063
+ self.arguments = arguments
1064
+ self.argumentskw = argumentskw
1065
+
1066
+ end
1067
+
1068
+ def self.type
1069
+ Types::YIELD
1070
+ end
1071
+
1072
+ def self.parse(params)
1073
+
1074
+ self.check_gte('params list', 3, params.count)
1075
+ self.check_equal('message type', self.type, params[0])
1076
+
1077
+ params.shift
1078
+ self.new(*params)
1079
+
1080
+ end
1081
+
1082
+ def payload
1083
+ payload = [self.class.type]
1084
+ payload.push(self.invocation_request)
1085
+ payload.push(self.options)
1086
+
1087
+ return payload if (self.arguments.nil? or self.arguments.empty?)
1088
+ payload.push(self.arguments)
1089
+
1090
+ return payload if (self.argumentskw.nil? or self.argumentskw.empty?)
1091
+ payload.push(self.argumentskw)
1092
+
1093
+ payload
1094
+ end
1095
+
1096
+ def to_s
1097
+ 'YIELD > ' + self.payload.to_s
1098
+ end
1099
+
1100
+ end
1101
+
1102
+ # Challenge
1103
+ # The "CHALLENGE" message is used with certain Authentication Methods. During authenticated session establishment, a *Router* sends a challenge message.
1104
+ # Formats:
1105
+ # [CHALLENGE, AuthMethod|string, Extra|dict]
1106
+ class Challenge < Base
1107
+ attr_accessor :authmethod, :extra
1108
+
1109
+ def initialize(authmethod, extra)
1110
+
1111
+ self.class.check_string('authmethod', authmethod)
1112
+ self.class.check_dict('extra', extra)
1113
+
1114
+ self.authmethod = authmethod
1115
+ self.extra = extra
1116
+
1117
+ end
1118
+
1119
+ def self.type
1120
+ Types::CHALLENGE
1121
+ end
1122
+
1123
+ def self.parse(params)
1124
+
1125
+ self.check_gte('params list', 3, params.count)
1126
+ self.check_equal('message type', self.type, params[0])
1127
+
1128
+ params.shift
1129
+ self.new(*params)
1130
+
1131
+ end
1132
+
1133
+ def payload
1134
+ payload = [self.class.type]
1135
+ payload.push(self.authmethod)
1136
+ payload.push(self.extra)
1137
+
1138
+ payload
1139
+ end
1140
+
1141
+ def to_s
1142
+ 'CHALLENGE > ' + self.payload.to_s
1143
+ end
1144
+
1145
+ end
1146
+
1147
+ # Authenticate
1148
+ # The "AUTHENTICATE" message is used with certain Authentication Methods. A *Client* having received a challenge is expected to respond by sending a signature or token.
1149
+ # Formats:
1150
+ # [AUTHENTICATE, Signature|string, Extra|dict]
1151
+ class Authenticate < Base
1152
+ attr_accessor :signature, :extra
1153
+
1154
+ def initialize(signature, extra)
1155
+
1156
+ self.class.check_string('signature', signature)
1157
+ self.class.check_dict('extra', extra)
1158
+
1159
+ self.signature = signature
1160
+ self.extra = extra
1161
+
1162
+ end
1163
+
1164
+ def self.type
1165
+ Types::AUTHENTICATE
1166
+ end
1167
+
1168
+ def self.parse(params)
1169
+
1170
+ self.check_gte('params list', 3, params.count)
1171
+ self.check_equal('message type', self.type, params[0])
1172
+
1173
+ params.shift
1174
+ self.new(*params)
1175
+
1176
+ end
1177
+
1178
+ def payload
1179
+ payload = [self.class.type]
1180
+ payload.push(self.signature)
1181
+ payload.push(self.extra)
1182
+
1183
+ payload
1184
+ end
1185
+
1186
+ def to_s
1187
+ 'AUTHENTICATE > ' + self.payload.to_s
1188
+ end
1189
+
1190
+ end
1191
+
1192
+ # Cancel
1193
+ # The "CANCEL" message is used with the Call Canceling advanced feature. A _Caller_ can cancel and issued call actively by sending a cancel message to the _Dealer_.
1194
+ # Formats:
1195
+ # [CANCEL, CALL.Request|id, Options|dict]
1196
+ class Cancel < Base
1197
+ attr_accessor :call_request, :options
1198
+
1199
+ def initialize(call_request, options)
1200
+
1201
+ self.class.check_id('call_request', call_request)
1202
+ self.class.check_dict('options', options)
1203
+
1204
+ self.call_request = call_request
1205
+ self.options = options
1206
+
1207
+ end
1208
+
1209
+ def self.type
1210
+ Types::CANCEL
1211
+ end
1212
+
1213
+ def self.parse(params)
1214
+
1215
+ self.check_gte('params list', 3, params.count)
1216
+ self.check_equal('message type', self.type, params[0])
1217
+
1218
+ params.shift
1219
+ self.new(*params)
1220
+
1221
+ end
1222
+
1223
+ def payload
1224
+ payload = [self.class.type]
1225
+ payload.push(self.call_request)
1226
+ payload.push(self.options)
1227
+
1228
+ payload
1229
+ end
1230
+
1231
+ def to_s
1232
+ 'CANCEL > ' + self.payload.to_s
1233
+ end
1234
+
1235
+ end
1236
+
1237
+ # Interrupt
1238
+ # The "INTERRUPT" message is used with the Call Canceling advanced feature. Upon receiving a cancel for a pending call, a _Dealer_ will issue an interrupt to the _Callee_.
1239
+ # Formats:
1240
+ # [INTERRUPT, INVOCATION.Request|id, Options|dict]
1241
+ class Interrupt < Base
1242
+ attr_accessor :invocation_request, :options
1243
+
1244
+ def initialize(invocation_request, options)
1245
+
1246
+ self.class.check_id('invocation_request', invocation_request)
1247
+ self.class.check_dict('options', options)
1248
+
1249
+ self.invocation_request = invocation_request
1250
+ self.options = options
1251
+
1252
+ end
1253
+
1254
+ def self.type
1255
+ Types::INTERRUPT
1256
+ end
1257
+
1258
+ def self.parse(params)
1259
+
1260
+ self.check_gte('params list', 3, params.count)
1261
+ self.check_equal('message type', self.type, params[0])
1262
+
1263
+ params.shift
1264
+ self.new(*params)
1265
+
1266
+ end
1267
+
1268
+ def payload
1269
+ payload = [self.class.type]
1270
+ payload.push(self.invocation_request)
1271
+ payload.push(self.options)
1272
+
1273
+ payload
1274
+ end
1275
+
1276
+ def to_s
1277
+ 'INTERRUPT > ' + self.payload.to_s
1278
+ end
1279
+
1280
+ end
1281
+
1282
+ end
1283
+ end