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