wamp_client 0.0.9 → 0.1.0

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