journeta 0.1.7 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. data/Gemfile +8 -0
  2. data/Gemfile.lock +20 -0
  3. data/{History.txt → HISTORY} +13 -1
  4. data/LICENSE +51 -0
  5. data/License.txt +2 -2
  6. data/{README.txt → README.rdoc} +12 -17
  7. data/Rakefile +46 -112
  8. data/VERSION +1 -0
  9. data/{examples/instant_messenger.rb → bin/journeta_instant_messenger.rb} +13 -0
  10. data/bin/journeta_mock_peers.rb +32 -0
  11. data/{examples/network_status.rb → bin/journeta_network_status.rb} +0 -0
  12. data/bin/journeta_peer_fuzzer.rb +54 -0
  13. data/{examples/queue_client.rb → bin/journeta_queue_client.rb} +0 -0
  14. data/{examples/queue_server.rb → bin/journeta_queue_server.rb} +0 -0
  15. data/bin/journeta_thread_leak_check.rb +16 -0
  16. data/bin/journeta_top.rb +73 -0
  17. data/{examples/instant_messenger_gui.rb → broken/journeta_instant_messenger_gui.rb} +0 -2
  18. data/broken/journeta_instant_messenger_shoes.rb +52 -0
  19. data/lib/diff.rb +280 -0
  20. data/lib/journeta.rb +1 -0
  21. data/lib/journeta/asynchronous.rb +2 -2
  22. data/lib/journeta/exception.rb +8 -0
  23. data/lib/journeta/journeta_engine.rb +4 -5
  24. data/lib/journeta/logger.rb +1 -1
  25. data/lib/journeta/peer_connection.rb +2 -2
  26. data/lib/journeta/peer_listener.rb +2 -2
  27. data/lib/journeta/presence_broadcaster.rb +19 -5
  28. data/lib/journeta/presence_listener.rb +8 -4
  29. data/lib/journeta/version.rb +6 -4
  30. data/rdoc/Array.html +199 -0
  31. data/rdoc/Diff.html +714 -0
  32. data/rdoc/Diffable.html +409 -0
  33. data/rdoc/Journeta.html +288 -0
  34. data/rdoc/Journeta/Asynchronous.html +429 -0
  35. data/rdoc/Journeta/Common.html +205 -0
  36. data/rdoc/Journeta/Common/BasicMessage.html +228 -0
  37. data/rdoc/Journeta/Common/DummyPeerHandler.html +237 -0
  38. data/rdoc/Journeta/Common/Job.html +279 -0
  39. data/rdoc/Journeta/Common/Shutdown.html +236 -0
  40. data/rdoc/Journeta/DefaultPeerHandler.html +248 -0
  41. data/rdoc/Journeta/DefaultPeerRegisteredHandler.html +249 -0
  42. data/rdoc/Journeta/DefaultPeerUnregisteredHandler.html +249 -0
  43. data/rdoc/Journeta/DefaultPeerUpdatedHandler.html +249 -0
  44. data/rdoc/Journeta/Engine.html +953 -0
  45. data/rdoc/Journeta/Logger.html +237 -0
  46. data/rdoc/Journeta/NotImplementedException.html +188 -0
  47. data/rdoc/Journeta/PeerConnection.html +549 -0
  48. data/rdoc/Journeta/PeerListener.html +276 -0
  49. data/rdoc/Journeta/PeerRegistry.html +804 -0
  50. data/rdoc/Journeta/PresenceBroadcaster.html +306 -0
  51. data/rdoc/Journeta/PresenceListener.html +300 -0
  52. data/rdoc/Journeta/PresenceMessage.html +321 -0
  53. data/rdoc/Journeta/VERSION.html +181 -0
  54. data/rdoc/README_rdoc.html +196 -0
  55. data/rdoc/String.html +199 -0
  56. data/rdoc/created.rid +20 -0
  57. data/rdoc/index.html +212 -0
  58. data/rdoc/lib/diff_rb.html +52 -0
  59. data/rdoc/lib/journeta/asynchronous_rb.html +60 -0
  60. data/rdoc/lib/journeta/common/basic_message_rb.html +52 -0
  61. data/rdoc/lib/journeta/common/dummy_peer_handler_rb.html +52 -0
  62. data/rdoc/lib/journeta/common/job_rb.html +52 -0
  63. data/rdoc/lib/journeta/common/shutdown_rb.html +52 -0
  64. data/rdoc/lib/journeta/exception_rb.html +55 -0
  65. data/rdoc/lib/journeta/journeta_engine_rb.html +62 -0
  66. data/rdoc/lib/journeta/logger_rb.html +55 -0
  67. data/rdoc/lib/journeta/peer_connection_rb.html +58 -0
  68. data/rdoc/lib/journeta/peer_handler_rb.html +52 -0
  69. data/rdoc/lib/journeta/peer_listener_rb.html +60 -0
  70. data/rdoc/lib/journeta/peer_registry_rb.html +54 -0
  71. data/rdoc/lib/journeta/presence_broadcaster_rb.html +57 -0
  72. data/rdoc/lib/journeta/presence_listener_rb.html +62 -0
  73. data/rdoc/lib/journeta/presence_message_rb.html +52 -0
  74. data/rdoc/lib/journeta/version_rb.html +52 -0
  75. data/rdoc/lib/journeta_rb.html +91 -0
  76. data/rdoc/rdoc.css +706 -0
  77. data/test/helper.rb +19 -0
  78. data/test/test_lifecycle.rb +49 -9
  79. data/website/images/arrow.png +0 -0
  80. data/website/images/banner.jpg +0 -0
  81. data/website/images/content_shadow.png +0 -0
  82. data/website/images/content_side.png +0 -0
  83. data/website/images/header.jpg +0 -0
  84. data/website/images/header_side.jpg +0 -0
  85. data/website/index.html +1 -1
  86. data/website/index.txt +1 -1
  87. data/website/stylesheets/reset.css +30 -0
  88. data/website/stylesheets/screen.css +1 -1
  89. metadata +152 -46
  90. data/test/test_event_broadcaster.rb +0 -15
  91. data/test/test_helper.rb +0 -4
  92. data/test/test_journeta.rb +0 -11
@@ -0,0 +1,953 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
7
+
8
+ <title>Class: Journeta::Engine</title>
9
+
10
+ <link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
11
+
12
+ <script src="../js/jquery.js" type="text/javascript"
13
+ charset="utf-8"></script>
14
+ <script src="../js/thickbox-compressed.js" type="text/javascript"
15
+ charset="utf-8"></script>
16
+ <script src="../js/quicksearch.js" type="text/javascript"
17
+ charset="utf-8"></script>
18
+ <script src="../js/darkfish.js" type="text/javascript"
19
+ charset="utf-8"></script>
20
+
21
+ </head>
22
+ <body class="class">
23
+
24
+ <div id="metadata">
25
+ <div id="home-metadata">
26
+ <div id="home-section" class="section">
27
+ <h3 class="section-header">
28
+ <a href="../index.html">Home</a>
29
+ <a href="../index.html#classes">Classes</a>
30
+ <a href="../index.html#methods">Methods</a>
31
+ </h3>
32
+ </div>
33
+ </div>
34
+
35
+ <div id="file-metadata">
36
+ <div id="file-list-section" class="section">
37
+ <h3 class="section-header">In Files</h3>
38
+ <div class="section-body">
39
+ <ul>
40
+
41
+ <li><a href="../lib/journeta/journeta_engine_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
42
+ class="thickbox" title="lib/journeta/journeta_engine.rb">lib/journeta/journeta_engine.rb</a></li>
43
+
44
+ </ul>
45
+ </div>
46
+ </div>
47
+
48
+
49
+ </div>
50
+
51
+ <div id="class-metadata">
52
+
53
+ <!-- Parent Class -->
54
+
55
+ <div id="parent-class-section" class="section">
56
+ <h3 class="section-header">Parent</h3>
57
+
58
+ <p class="link">Object</p>
59
+
60
+ </div>
61
+
62
+
63
+ <!-- Namespace Contents -->
64
+
65
+
66
+ <!-- Method Quickref -->
67
+
68
+ <div id="method-list-section" class="section">
69
+ <h3 class="section-header">Methods</h3>
70
+ <ul class="link-list">
71
+
72
+ <li><a href="#method-c-new">::new</a></li>
73
+
74
+ <li><a href="#method-i-known_groups">#known_groups</a></li>
75
+
76
+ <li><a href="#method-i-known_peers">#known_peers</a></li>
77
+
78
+ <li><a href="#method-i-known_peers_in_group">#known_peers_in_group</a></li>
79
+
80
+ <li><a href="#method-i-register_peer">#register_peer</a></li>
81
+
82
+ <li><a href="#method-i-send_to_known_peers">#send_to_known_peers</a></li>
83
+
84
+ <li><a href="#method-i-send_to_peer">#send_to_peer</a></li>
85
+
86
+ <li><a href="#method-i-start">#start</a></li>
87
+
88
+ <li><a href="#method-i-stop">#stop</a></li>
89
+
90
+ <li><a href="#method-i-unregister_peer">#unregister_peer</a></li>
91
+
92
+ </ul>
93
+ </div>
94
+
95
+
96
+ <!-- Included Modules -->
97
+
98
+ <div id="includes-section" class="section">
99
+ <h3 class="section-header">Included Modules</h3>
100
+ <ul class="link-list">
101
+
102
+
103
+ <li><span class="include">Logger</span></li>
104
+
105
+
106
+ </ul>
107
+ </div>
108
+
109
+ </div>
110
+
111
+ <div id="project-metadata">
112
+
113
+
114
+ <div id="fileindex-section" class="section project-section">
115
+ <h3 class="section-header">Files</h3>
116
+ <ul>
117
+
118
+ <li class="file"><a href="../README_rdoc.html">README.rdoc</a></li>
119
+
120
+ </ul>
121
+ </div>
122
+
123
+
124
+ <div id="classindex-section" class="section project-section">
125
+ <h3 class="section-header">Class Index
126
+ <span class="search-toggle"><img src="../images/find.png"
127
+ height="16" width="16" alt="[+]"
128
+ title="show/hide quicksearch" /></span></h3>
129
+ <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
130
+ <fieldset>
131
+ <legend>Quicksearch</legend>
132
+ <input type="text" name="quicksearch" value=""
133
+ class="quicksearch-field" />
134
+ </fieldset>
135
+ </form>
136
+
137
+ <ul class="link-list">
138
+
139
+ <li><a href="../Journeta/Asynchronous.html">Journeta::Asynchronous</a></li>
140
+
141
+ <li><a href="../Journeta/Common.html">Journeta::Common</a></li>
142
+
143
+ <li><a href="../Journeta/Common/BasicMessage.html">Journeta::Common::BasicMessage</a></li>
144
+
145
+ <li><a href="../Journeta/Common/DummyPeerHandler.html">Journeta::Common::DummyPeerHandler</a></li>
146
+
147
+ <li><a href="../Journeta/Common/Job.html">Journeta::Common::Job</a></li>
148
+
149
+ <li><a href="../Journeta/Common/Shutdown.html">Journeta::Common::Shutdown</a></li>
150
+
151
+ <li><a href="../Journeta/DefaultPeerHandler.html">Journeta::DefaultPeerHandler</a></li>
152
+
153
+ <li><a href="../Journeta/DefaultPeerRegisteredHandler.html">Journeta::DefaultPeerRegisteredHandler</a></li>
154
+
155
+ <li><a href="../Journeta/DefaultPeerUnregisteredHandler.html">Journeta::DefaultPeerUnregisteredHandler</a></li>
156
+
157
+ <li><a href="../Journeta/DefaultPeerUpdatedHandler.html">Journeta::DefaultPeerUpdatedHandler</a></li>
158
+
159
+ <li><a href="../Journeta/Engine.html">Journeta::Engine</a></li>
160
+
161
+ <li><a href="../Journeta/Logger.html">Journeta::Logger</a></li>
162
+
163
+ <li><a href="../Journeta/NotImplementedException.html">Journeta::NotImplementedException</a></li>
164
+
165
+ <li><a href="../Journeta/PeerConnection.html">Journeta::PeerConnection</a></li>
166
+
167
+ <li><a href="../Journeta/PeerListener.html">Journeta::PeerListener</a></li>
168
+
169
+ <li><a href="../Journeta/PeerRegistry.html">Journeta::PeerRegistry</a></li>
170
+
171
+ <li><a href="../Journeta/PresenceBroadcaster.html">Journeta::PresenceBroadcaster</a></li>
172
+
173
+ <li><a href="../Journeta/PresenceListener.html">Journeta::PresenceListener</a></li>
174
+
175
+ <li><a href="../Journeta/PresenceMessage.html">Journeta::PresenceMessage</a></li>
176
+
177
+ <li><a href="../Array.html">Array</a></li>
178
+
179
+ <li><a href="../Diff.html">Diff</a></li>
180
+
181
+ <li><a href="../Diffable.html">Diffable</a></li>
182
+
183
+ <li><a href="../String.html">String</a></li>
184
+
185
+ </ul>
186
+ <div id="no-class-search-results" style="display: none;">No matching classes.</div>
187
+ </div>
188
+
189
+
190
+ </div>
191
+ </div>
192
+
193
+ <div id="documentation">
194
+ <h1 class="class">Journeta::Engine</h1>
195
+
196
+ <div id="description">
197
+ <p>
198
+ The primary fascade of the entire <tt>Journeta</tt> library, which
199
+ composite a number of objects running asynchronously to the primary
200
+ application <tt>Thread</tt>. Use of this fascade requires a minimal amount
201
+ of lifecycle management on your part to start and stop the engine at
202
+ appropriate times. (Usually only at application startup and shutdown,
203
+ respectively.)
204
+ </p>
205
+
206
+ </div>
207
+
208
+ <!-- Constants -->
209
+
210
+ <div id="constants-list" class="section">
211
+ <h3 class="section-header">Constants</h3>
212
+ <dl>
213
+
214
+ <dt><a name="DEFAULT_PEER_PORT">DEFAULT_PEER_PORT</a></dt>
215
+
216
+ <dd class="description"><p>
217
+ Incoming direct peer TCP connections will use this port.
218
+ </p></dd>
219
+
220
+
221
+ <dt><a name="DEFAULT_PRESENCE_PORT">DEFAULT_PRESENCE_PORT</a></dt>
222
+
223
+ <dd class="description"><p>
224
+ On UDP port on which we send/receive peer presence messages.
225
+ </p></dd>
226
+
227
+
228
+ <dt><a name="DEFAULT_PRESENCE_NETWORK">DEFAULT_PRESENCE_NETWORK</a></dt>
229
+
230
+ <dd class="description"><p>
231
+ Addresses 224.0.0.0 through 239.255.255.255 are reserved for multicast
232
+ messages.
233
+ </p></dd>
234
+
235
+
236
+ <dt><a name="DEFAULT_PRESENCE_PERIOD">DEFAULT_PRESENCE_PERIOD</a></dt>
237
+
238
+ <dd class="description"><p>
239
+ The wait time, in seconds, between rebroadcasts of peer presence.
240
+ </p></dd>
241
+
242
+
243
+ </dl>
244
+ </div>
245
+
246
+
247
+ <!-- Attributes -->
248
+
249
+ <div id="attribute-method-details" class="method-section section">
250
+ <h3 class="section-header">Attributes</h3>
251
+
252
+
253
+ <div id="uuid-attribute-method" class="method-detail">
254
+ <a name="uuid"></a>
255
+
256
+ <div class="method-heading attribute-method-heading">
257
+ <span class="method-name">uuid</span><span
258
+ class="attribute-access-type">[R]</span>
259
+ </div>
260
+
261
+ <div class="method-description">
262
+
263
+ <p>
264
+ A supposedly universally unique id for this instance.
265
+ </p>
266
+
267
+ </div>
268
+ </div>
269
+
270
+ <div id="groups-attribute-method" class="method-detail">
271
+ <a name="groups"></a>
272
+
273
+ <div class="method-heading attribute-method-heading">
274
+ <span class="method-name">groups</span><span
275
+ class="attribute-access-type">[R]</span>
276
+ </div>
277
+
278
+ <div class="method-description">
279
+
280
+ <p>
281
+ An array of peer network names. Ex: [&#8216;Preston Lee Ventures
282
+ Test&#8217;, &#8216;quick_chat_app&#8217;] An empty array indicates
283
+ implicit membership in all discovered groups.
284
+ </p>
285
+
286
+ </div>
287
+ </div>
288
+
289
+ <div id="presence-broadcaster-attribute-method" class="method-detail">
290
+ <a name="presence_broadcaster"></a>
291
+
292
+ <div class="method-heading attribute-method-heading">
293
+ <span class="method-name">presence_broadcaster</span><span
294
+ class="attribute-access-type">[R]</span>
295
+ </div>
296
+
297
+ <div class="method-description">
298
+
299
+ <p>
300
+ Continuously sends out &#8220;i&#8217;m here&#8221; presence messages to
301
+ the local network
302
+ </p>
303
+
304
+ </div>
305
+ </div>
306
+
307
+ <div id="presence-listener-attribute-method" class="method-detail">
308
+ <a name="presence_listener"></a>
309
+
310
+ <div class="method-heading attribute-method-heading">
311
+ <span class="method-name">presence_listener</span><span
312
+ class="attribute-access-type">[R]</span>
313
+ </div>
314
+
315
+ <div class="method-description">
316
+
317
+ <p>
318
+ continuously listens for &#8220;i&#8217;m here&#8221; presence messages
319
+ from other peers
320
+ </p>
321
+
322
+ </div>
323
+ </div>
324
+
325
+ <div id="presence-port-attribute-method" class="method-detail">
326
+ <a name="presence_port"></a>
327
+
328
+ <div class="method-heading attribute-method-heading">
329
+ <span class="method-name">presence_port</span><span
330
+ class="attribute-access-type">[R]</span>
331
+ </div>
332
+
333
+ <div class="method-description">
334
+
335
+ <p>
336
+ The UDP port for event broadcast messages.
337
+ </p>
338
+
339
+ </div>
340
+ </div>
341
+
342
+ <div id="presence-address-attribute-method" class="method-detail">
343
+ <a name="presence_address"></a>
344
+
345
+ <div class="method-heading attribute-method-heading">
346
+ <span class="method-name">presence_address</span><span
347
+ class="attribute-access-type">[R]</span>
348
+ </div>
349
+
350
+ <div class="method-description">
351
+
352
+ <p>
353
+ The UDP network address used for broadcast messages.
354
+ </p>
355
+
356
+ </div>
357
+ </div>
358
+
359
+ <div id="presence-period-attribute-method" class="method-detail">
360
+ <a name="presence_period"></a>
361
+
362
+ <div class="method-heading attribute-method-heading">
363
+ <span class="method-name">presence_period</span><span
364
+ class="attribute-access-type">[R]</span>
365
+ </div>
366
+
367
+ <div class="method-description">
368
+
369
+ <p>
370
+ The amount of time between presence broadcasts.
371
+ </p>
372
+
373
+ </div>
374
+ </div>
375
+
376
+ <div id="peer-listener-attribute-method" class="method-detail">
377
+ <a name="peer_listener"></a>
378
+
379
+ <div class="method-heading attribute-method-heading">
380
+ <span class="method-name">peer_listener</span><span
381
+ class="attribute-access-type">[R]</span>
382
+ </div>
383
+
384
+ <div class="method-description">
385
+
386
+ <p>
387
+ Constantly listens for incoming peer sessions
388
+ </p>
389
+
390
+ </div>
391
+ </div>
392
+
393
+ <div id="peer-handler-attribute-method" class="method-detail">
394
+ <a name="peer_handler"></a>
395
+
396
+ <div class="method-heading attribute-method-heading">
397
+ <span class="method-name">peer_handler</span><span
398
+ class="attribute-access-type">[R]</span>
399
+ </div>
400
+
401
+ <div class="method-description">
402
+
403
+ <p>
404
+ Application logic which processes session data.
405
+ </p>
406
+
407
+ </div>
408
+ </div>
409
+
410
+ <div id="peer-registered-handler-attribute-method" class="method-detail">
411
+ <a name="peer_registered_handler"></a>
412
+
413
+ <div class="method-heading attribute-method-heading">
414
+ <span class="method-name">peer_registered_handler</span><span
415
+ class="attribute-access-type">[R]</span>
416
+ </div>
417
+
418
+ <div class="method-description">
419
+
420
+ <p>
421
+ Application logic which gets notified when a peer comes online.
422
+ </p>
423
+
424
+ </div>
425
+ </div>
426
+
427
+ <div id="peer-updated-handler-attribute-method" class="method-detail">
428
+ <a name="peer_updated_handler"></a>
429
+
430
+ <div class="method-heading attribute-method-heading">
431
+ <span class="method-name">peer_updated_handler</span><span
432
+ class="attribute-access-type">[R]</span>
433
+ </div>
434
+
435
+ <div class="method-description">
436
+
437
+ <p>
438
+ Application logic which gets notified when a peer comes online.
439
+ </p>
440
+
441
+ </div>
442
+ </div>
443
+
444
+ <div id="peer-unregistered-handler-attribute-method" class="method-detail">
445
+ <a name="peer_unregistered_handler"></a>
446
+
447
+ <div class="method-heading attribute-method-heading">
448
+ <span class="method-name">peer_unregistered_handler</span><span
449
+ class="attribute-access-type">[R]</span>
450
+ </div>
451
+
452
+ <div class="method-description">
453
+
454
+ <p>
455
+ Application logic which gets notified when a peer goes offline.
456
+ </p>
457
+
458
+ </div>
459
+ </div>
460
+
461
+ <div id="peer-port-attribute-method" class="method-detail">
462
+ <a name="peer_port"></a>
463
+
464
+ <div class="method-heading attribute-method-heading">
465
+ <span class="method-name">peer_port</span><span
466
+ class="attribute-access-type">[R]</span>
467
+ </div>
468
+
469
+ <div class="method-description">
470
+
471
+ <p>
472
+ The TCP port used to receive direct peer messages.
473
+ </p>
474
+
475
+ </div>
476
+ </div>
477
+
478
+ <div id="peer-registry-attribute-method" class="method-detail">
479
+ <a name="peer_registry"></a>
480
+
481
+ <div class="method-heading attribute-method-heading">
482
+ <span class="method-name">peer_registry</span><span
483
+ class="attribute-access-type">[R]</span>
484
+ </div>
485
+
486
+ <div class="method-description">
487
+
488
+ <p>
489
+ Authoritative peer availability database.
490
+ </p>
491
+
492
+ </div>
493
+ </div>
494
+
495
+ </div>
496
+
497
+
498
+ <!-- Methods -->
499
+
500
+ <div id="public-class-method-details" class="method-section section">
501
+ <h3 class="section-header">Public Class Methods</h3>
502
+
503
+
504
+ <div id="new-method" class="method-detail ">
505
+ <a name="method-c-new"></a>
506
+
507
+ <div class="method-heading">
508
+
509
+ <span class="method-name">new</span><span
510
+ class="method-args">(configuration ={})</span>
511
+ <span class="method-click-advice">click to toggle source</span>
512
+
513
+ </div>
514
+
515
+ <div class="method-description">
516
+
517
+ <p>
518
+ Nothing magical. Just creation of internal components and configuration
519
+ setup.
520
+ </p>
521
+
522
+
523
+
524
+ <div class="method-source-code"
525
+ id="new-source">
526
+ <pre>
527
+ <span class="ruby-comment cmt"># File lib/journeta/journeta_engine.rb, line 82</span>
528
+ 82: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">configuration</span> ={})
529
+ 83: <span class="ruby-comment cmt"># TODO make guaranteed to be unique.</span>
530
+ 84: <span class="ruby-ivar">@uuid</span> = <span class="ruby-identifier">configuration</span>[<span class="ruby-value">:uuid</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">rand</span>(<span class="ruby-value">2</span> <span class="ruby-operator">**</span> <span class="ruby-value">31</span>)
531
+ 85: <span class="ruby-ivar">@groups</span> = <span class="ruby-identifier">configuration</span>[<span class="ruby-value">:groups</span>]
532
+ 86:
533
+ 87:
534
+ 88: <span class="ruby-ivar">@peer_port</span> = <span class="ruby-identifier">configuration</span>[<span class="ruby-value">:peer_port</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">DEFAULT_PEER_PORT</span>
535
+ 89: <span class="ruby-ivar">@peer_handler</span> = <span class="ruby-identifier">configuration</span>[<span class="ruby-value">:peer_handler</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">DefaultPeerHandler</span>.<span class="ruby-identifier">new</span>
536
+ 90: <span class="ruby-ivar">@peer_registered_handler</span> = <span class="ruby-identifier">configuration</span>[<span class="ruby-value">:peer_registered_handler</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">DefaultPeerRegisteredHandler</span>.<span class="ruby-identifier">new</span>
537
+ 91: <span class="ruby-ivar">@peer_updated_handler</span> = <span class="ruby-identifier">configuration</span>[<span class="ruby-value">:peer_updated_handler</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">DefaultPeerUpdatedHandler</span>.<span class="ruby-identifier">new</span>
538
+ 92: <span class="ruby-ivar">@peer_unregistered_handler</span> = <span class="ruby-identifier">configuration</span>[<span class="ruby-value">:peer_unregistered_handler</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">DefaultPeerUnregisteredHandler</span>.<span class="ruby-identifier">new</span>
539
+ 93:
540
+ 94: <span class="ruby-ivar">@presence_port</span> = <span class="ruby-identifier">configuration</span>[<span class="ruby-value">:presence_port</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">DEFAULT_PRESENCE_PORT</span>
541
+ 95: <span class="ruby-ivar">@presence_address</span> = <span class="ruby-identifier">configuration</span>[<span class="ruby-value">:presence_address</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">DEFAULT_PRESENCE_NETWORK</span>
542
+ 96: <span class="ruby-ivar">@presence_period</span> = <span class="ruby-identifier">configuration</span>[<span class="ruby-value">:presence_period</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">DEFAULT_PRESENCE_PERIOD</span>
543
+ 97:
544
+ 98: <span class="ruby-comment cmt"># Inversion of Control is used in the following components to allow for some semblance of testing.</span>
545
+ 99: <span class="ruby-ivar">@peer_listener</span> = <span class="ruby-identifier">configuration</span>[<span class="ruby-value">:peer_listener</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">Journeta</span><span class="ruby-operator">::</span><span class="ruby-constant">PeerListener</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>)
546
+ 100: <span class="ruby-ivar">@peer_registry</span> = <span class="ruby-identifier">configuration</span>[<span class="ruby-value">:peer_registry</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">PeerRegistry</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>)
547
+ 101: <span class="ruby-ivar">@presence_listener</span> = <span class="ruby-identifier">configuration</span>[<span class="ruby-value">:presence_listener</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">PresenceListener</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>)
548
+ 102: <span class="ruby-ivar">@presence_broadcaster</span> = <span class="ruby-identifier">configuration</span>[<span class="ruby-value">:presence_broadcaster</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">PresenceBroadcaster</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>)
549
+ 103: <span class="ruby-keyword kw">end</span></pre>
550
+ </div>
551
+
552
+ </div>
553
+
554
+
555
+
556
+
557
+ </div>
558
+
559
+
560
+ </div>
561
+
562
+ <div id="public-instance-method-details" class="method-section section">
563
+ <h3 class="section-header">Public Instance Methods</h3>
564
+
565
+
566
+ <div id="known-groups-method" class="method-detail ">
567
+ <a name="method-i-known_groups"></a>
568
+
569
+ <div class="method-heading">
570
+
571
+ <span class="method-name">known_groups</span><span
572
+ class="method-args">()</span>
573
+ <span class="method-click-advice">click to toggle source</span>
574
+
575
+ </div>
576
+
577
+ <div class="method-description">
578
+
579
+
580
+
581
+
582
+
583
+ <div class="method-source-code"
584
+ id="known-groups-source">
585
+ <pre>
586
+ <span class="ruby-comment cmt"># File lib/journeta/journeta_engine.rb, line 170</span>
587
+ 170: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">known_groups</span>()
588
+ 171: <span class="ruby-identifier">s</span> = <span class="ruby-constant">Set</span>.<span class="ruby-identifier">new</span>
589
+ 172: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">known_peers</span>(<span class="ruby-keyword kw">true</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">uuid</span>, <span class="ruby-identifier">peer</span><span class="ruby-operator">|</span>
590
+ 173: <span class="ruby-identifier">s</span>.<span class="ruby-identifier">merge</span> <span class="ruby-identifier">peer</span>.<span class="ruby-identifier">groups</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">peer</span>.<span class="ruby-identifier">groups</span>.<span class="ruby-identifier">nil?</span>
591
+ 174: <span class="ruby-keyword kw">end</span>
592
+ 175: <span class="ruby-identifier">s</span>.<span class="ruby-identifier">to_a</span>
593
+ 176: <span class="ruby-keyword kw">end</span></pre>
594
+ </div>
595
+
596
+ </div>
597
+
598
+
599
+
600
+
601
+ </div>
602
+
603
+
604
+ <div id="known-peers-method" class="method-detail ">
605
+ <a name="method-i-known_peers"></a>
606
+
607
+ <div class="method-heading">
608
+
609
+ <span class="method-name">known_peers</span><span
610
+ class="method-args">(all_groups = false)</span>
611
+ <span class="method-click-advice">click to toggle source</span>
612
+
613
+ </div>
614
+
615
+ <div class="method-description">
616
+
617
+ <p>
618
+ Returns metadata on all known peers in a hash, keyed by the uuid of each. A
619
+ record corresponding to this peer is not included.
620
+ </p>
621
+
622
+
623
+
624
+ <div class="method-source-code"
625
+ id="known-peers-source">
626
+ <pre>
627
+ <span class="ruby-comment cmt"># File lib/journeta/journeta_engine.rb, line 158</span>
628
+ 158: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">known_peers</span>(<span class="ruby-identifier">all_groups</span> = <span class="ruby-keyword kw">false</span>)
629
+ 159: <span class="ruby-identifier">peer_registry</span>.<span class="ruby-identifier">all</span>(<span class="ruby-identifier">all_groups</span>)
630
+ 160: <span class="ruby-keyword kw">end</span></pre>
631
+ </div>
632
+
633
+ </div>
634
+
635
+
636
+
637
+
638
+ </div>
639
+
640
+
641
+ <div id="known-peers-in-group-method" class="method-detail ">
642
+ <a name="method-i-known_peers_in_group"></a>
643
+
644
+ <div class="method-heading">
645
+
646
+ <span class="method-name">known_peers_in_group</span><span
647
+ class="method-args">(group_name)</span>
648
+ <span class="method-click-advice">click to toggle source</span>
649
+
650
+ </div>
651
+
652
+ <div class="method-description">
653
+
654
+
655
+
656
+
657
+
658
+ <div class="method-source-code"
659
+ id="known-peers-in-group-source">
660
+ <pre>
661
+ <span class="ruby-comment cmt"># File lib/journeta/journeta_engine.rb, line 162</span>
662
+ 162: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">known_peers_in_group</span>(<span class="ruby-identifier">group_name</span>)
663
+ 163: <span class="ruby-identifier">s</span> = {}
664
+ 164: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">known_peers</span>(<span class="ruby-keyword kw">true</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">uuid</span>, <span class="ruby-identifier">peer</span><span class="ruby-operator">|</span>
665
+ 165: <span class="ruby-identifier">s</span>[<span class="ruby-identifier">uuid</span>] = <span class="ruby-identifier">peer</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">peer</span>.<span class="ruby-identifier">groups</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">group_name</span>)
666
+ 166: <span class="ruby-keyword kw">end</span>
667
+ 167: <span class="ruby-identifier">s</span>
668
+ 168: <span class="ruby-keyword kw">end</span></pre>
669
+ </div>
670
+
671
+ </div>
672
+
673
+
674
+
675
+
676
+ </div>
677
+
678
+
679
+ <div id="register-peer-method" class="method-detail ">
680
+ <a name="method-i-register_peer"></a>
681
+
682
+ <div class="method-heading">
683
+
684
+ <span class="method-name">register_peer</span><span
685
+ class="method-args">(peer)</span>
686
+ <span class="method-click-advice">click to toggle source</span>
687
+
688
+ </div>
689
+
690
+ <div class="method-description">
691
+
692
+ <p>
693
+ Adds (or updates) the given <tt>PeerConnection</tt>. If a peer of the same
694
+ UUID is found, the existing record will be updated and given instance
695
+ #PeerConnection#stop&#8216;d. This prevents pending outbound data from
696
+ being accidentally dropped.
697
+ </p>
698
+
699
+
700
+
701
+ <div class="method-source-code"
702
+ id="register-peer-source">
703
+ <pre>
704
+ <span class="ruby-comment cmt"># File lib/journeta/journeta_engine.rb, line 181</span>
705
+ 181: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">register_peer</span>(<span class="ruby-identifier">peer</span>)
706
+ 182: <span class="ruby-identifier">putsd</span> <span class="ruby-node">&quot;Registering peer: #{peer.uuid}&quot;</span>
707
+ 183: <span class="ruby-identifier">peer_registry</span>.<span class="ruby-identifier">register</span>(<span class="ruby-identifier">peer</span>)
708
+ 184: <span class="ruby-keyword kw">end</span></pre>
709
+ </div>
710
+
711
+ </div>
712
+
713
+
714
+
715
+
716
+ </div>
717
+
718
+
719
+ <div id="send-to-known-peers-method" class="method-detail ">
720
+ <a name="method-i-send_to_known_peers"></a>
721
+
722
+ <div class="method-heading">
723
+
724
+ <span class="method-name">send_to_known_peers</span><span
725
+ class="method-args">(payload)</span>
726
+ <span class="method-click-advice">click to toggle source</span>
727
+
728
+ </div>
729
+
730
+ <div class="method-description">
731
+
732
+ <p>
733
+ Sends the given object to all peers in one of the # associated with this
734
+ instance. The object will be marshalled via YAML, so anything the YAML
735
+ serializer misses won&#8217;t make it to the other side(s). The return
736
+ value is undefined.
737
+ </p>
738
+
739
+
740
+
741
+ <div class="method-source-code"
742
+ id="send-to-known-peers-source">
743
+ <pre>
744
+ <span class="ruby-comment cmt"># File lib/journeta/journeta_engine.rb, line 144</span>
745
+ 144: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_to_known_peers</span>(<span class="ruby-identifier">payload</span>)
746
+ 145: <span class="ruby-comment cmt"># Delegate directly.</span>
747
+ 146: <span class="ruby-identifier">peer_registry</span>.<span class="ruby-identifier">send_to_known_peers</span>(<span class="ruby-identifier">payload</span>)
748
+ 147: <span class="ruby-keyword kw">end</span></pre>
749
+ </div>
750
+
751
+ </div>
752
+
753
+
754
+
755
+
756
+ </div>
757
+
758
+
759
+ <div id="send-to-peer-method" class="method-detail ">
760
+ <a name="method-i-send_to_peer"></a>
761
+
762
+ <div class="method-heading">
763
+
764
+ <span class="method-name">send_to_peer</span><span
765
+ class="method-args">(peer_uuid, payload)</span>
766
+ <span class="method-click-advice">click to toggle source</span>
767
+
768
+ </div>
769
+
770
+ <div class="method-description">
771
+
772
+ <p>
773
+ Send the given object to the peer of the given UUID, if available. The
774
+ return value is undefined.
775
+ </p>
776
+
777
+
778
+
779
+ <div class="method-source-code"
780
+ id="send-to-peer-source">
781
+ <pre>
782
+ <span class="ruby-comment cmt"># File lib/journeta/journeta_engine.rb, line 151</span>
783
+ 151: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_to_peer</span>(<span class="ruby-identifier">peer_uuid</span>, <span class="ruby-identifier">payload</span>)
784
+ 152: <span class="ruby-comment cmt"># Delegate directly.</span>
785
+ 153: <span class="ruby-identifier">peer_registry</span>.<span class="ruby-identifier">send_to_peer</span>(<span class="ruby-identifier">peer_uuid</span>, <span class="ruby-identifier">payload</span>)
786
+ 154: <span class="ruby-keyword kw">end</span></pre>
787
+ </div>
788
+
789
+ </div>
790
+
791
+
792
+
793
+
794
+ </div>
795
+
796
+
797
+ <div id="start-method" class="method-detail ">
798
+ <a name="method-i-start"></a>
799
+
800
+ <div class="method-heading">
801
+
802
+ <span class="method-name">start</span><span
803
+ class="method-args">()</span>
804
+ <span class="method-click-advice">click to toggle source</span>
805
+
806
+ </div>
807
+
808
+ <div class="method-description">
809
+
810
+ <p>
811
+ Starts sub-comonents which have their own life-cycle requirements. The
812
+ registry itself does not have a dedication thread, and thus does not need
813
+ to be started.
814
+ </p>
815
+
816
+
817
+
818
+ <div class="method-source-code"
819
+ id="start-source">
820
+ <pre>
821
+ <span class="ruby-comment cmt"># File lib/journeta/journeta_engine.rb, line 108</span>
822
+ 108: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">start</span>
823
+ 109: <span class="ruby-ivar">@peer_registry</span>.<span class="ruby-identifier">start</span>
824
+ 110:
825
+ 111: <span class="ruby-comment cmt"># Start a peer listener first so we don't risk missing a connection attempt.</span>
826
+ 112: <span class="ruby-identifier">putsd</span> <span class="ruby-node">&quot;Starting #{@peer_listener.class.to_s}&quot;</span>
827
+ 113: <span class="ruby-ivar">@peer_listener</span>.<span class="ruby-identifier">start</span>
828
+ 114:
829
+ 115: <span class="ruby-comment cmt"># Start listening for peer presence announcements next.</span>
830
+ 116: <span class="ruby-identifier">putsd</span> <span class="ruby-node">&quot;Starting #{@presence_listener.class.to_s}&quot;</span>
831
+ 117: <span class="ruby-ivar">@presence_listener</span>.<span class="ruby-identifier">start</span>
832
+ 118:
833
+ 119: <span class="ruby-comment cmt"># Now that we're all set up, start sending our own presence events</span>
834
+ 120: <span class="ruby-comment cmt"># so peer can start sending us data!</span>
835
+ 121: <span class="ruby-identifier">putsd</span> <span class="ruby-node">&quot;Starting #{@presence_broadcaster.class.to_s}&quot;</span>
836
+ 122: <span class="ruby-ivar">@presence_broadcaster</span>.<span class="ruby-identifier">start</span>
837
+ 123: <span class="ruby-keyword kw">end</span></pre>
838
+ </div>
839
+
840
+ </div>
841
+
842
+
843
+
844
+
845
+ </div>
846
+
847
+
848
+ <div id="stop-method" class="method-detail ">
849
+ <a name="method-i-stop"></a>
850
+
851
+ <div class="method-heading">
852
+
853
+ <span class="method-name">stop</span><span
854
+ class="method-args">()</span>
855
+ <span class="method-click-advice">click to toggle source</span>
856
+
857
+ </div>
858
+
859
+ <div class="method-description">
860
+
861
+
862
+
863
+
864
+
865
+ <div class="method-source-code"
866
+ id="stop-source">
867
+ <pre>
868
+ <span class="ruby-comment cmt"># File lib/journeta/journeta_engine.rb, line 126</span>
869
+ 126: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stop</span>
870
+ 127: <span class="ruby-comment cmt"># Stop broadcasting presence.</span>
871
+ 128: <span class="ruby-ivar">@presence_broadcaster</span>.<span class="ruby-identifier">stop</span>
872
+ 129: <span class="ruby-comment cmt"># Stop listening for presence events, which prevents new peer registrations</span>
873
+ 130: <span class="ruby-ivar">@presence_listener</span>.<span class="ruby-identifier">stop</span>
874
+ 131: <span class="ruby-comment cmt"># Stop listening for incoming peer data.</span>
875
+ 132: <span class="ruby-ivar">@peer_listener</span>.<span class="ruby-identifier">stop</span>
876
+ 133:
877
+ 134: <span class="ruby-comment cmt"># While the registry does not have its own thread, it is in charge of managing</span>
878
+ 135: <span class="ruby-comment cmt"># +PeerConnection+s which DO have individual threads. This call</span>
879
+ 136: <span class="ruby-comment cmt"># forcefully terminates all connections, which may or may not be actively passing data.</span>
880
+ 137: <span class="ruby-comment cmt"># @peer_registry.unregister_all</span>
881
+ 138: <span class="ruby-ivar">@peer_registry</span>.<span class="ruby-identifier">stop</span>
882
+ 139: <span class="ruby-keyword kw">end</span></pre>
883
+ </div>
884
+
885
+ </div>
886
+
887
+
888
+
889
+
890
+ </div>
891
+
892
+
893
+ <div id="unregister-peer-method" class="method-detail ">
894
+ <a name="method-i-unregister_peer"></a>
895
+
896
+ <div class="method-heading">
897
+
898
+ <span class="method-name">unregister_peer</span><span
899
+ class="method-args">(peer)</span>
900
+ <span class="method-click-advice">click to toggle source</span>
901
+
902
+ </div>
903
+
904
+ <div class="method-description">
905
+
906
+ <p>
907
+ Forcefully unregisters the given #<a
908
+ href="PeerConnection.html">PeerConnection</a>, though this is of limited
909
+ use since the #<a href="PresenceListener.html">PresenceListener</a> will
910
+ eventually automatically re-register the peers UUID if it&#8217;s still
911
+ online.
912
+ </p>
913
+
914
+
915
+
916
+ <div class="method-source-code"
917
+ id="unregister-peer-source">
918
+ <pre>
919
+ <span class="ruby-comment cmt"># File lib/journeta/journeta_engine.rb, line 189</span>
920
+ 189: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unregister_peer</span>(<span class="ruby-identifier">peer</span>)
921
+ 190: <span class="ruby-identifier">peer_registry</span>.<span class="ruby-identifier">unregister</span>(<span class="ruby-identifier">peer</span>)
922
+ 191: <span class="ruby-keyword kw">end</span></pre>
923
+ </div>
924
+
925
+ </div>
926
+
927
+
928
+
929
+
930
+ </div>
931
+
932
+
933
+ </div>
934
+
935
+
936
+ </div>
937
+
938
+
939
+ <div id="rdoc-debugging-section-dump" class="debugging-section">
940
+
941
+ <p>Disabled; run with --debug to generate this.</p>
942
+
943
+ </div>
944
+
945
+ <div id="validator-badges">
946
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
947
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
948
+ Rdoc Generator</a> 1.1.6</small>.</p>
949
+ </div>
950
+
951
+ </body>
952
+ </html>
953
+