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,276 @@
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::PeerListener</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/peer_listener_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
42
+ class="thickbox" title="lib/journeta/peer_listener.rb">lib/journeta/peer_listener.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"><a href="Asynchronous.html">Journeta::Asynchronous</a></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-i-go">#go</a></li>
73
+
74
+ </ul>
75
+ </div>
76
+
77
+
78
+ <!-- Included Modules -->
79
+
80
+ </div>
81
+
82
+ <div id="project-metadata">
83
+
84
+
85
+ <div id="fileindex-section" class="section project-section">
86
+ <h3 class="section-header">Files</h3>
87
+ <ul>
88
+
89
+ <li class="file"><a href="../README_rdoc.html">README.rdoc</a></li>
90
+
91
+ </ul>
92
+ </div>
93
+
94
+
95
+ <div id="classindex-section" class="section project-section">
96
+ <h3 class="section-header">Class Index
97
+ <span class="search-toggle"><img src="../images/find.png"
98
+ height="16" width="16" alt="[+]"
99
+ title="show/hide quicksearch" /></span></h3>
100
+ <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
101
+ <fieldset>
102
+ <legend>Quicksearch</legend>
103
+ <input type="text" name="quicksearch" value=""
104
+ class="quicksearch-field" />
105
+ </fieldset>
106
+ </form>
107
+
108
+ <ul class="link-list">
109
+
110
+ <li><a href="../Journeta/Asynchronous.html">Journeta::Asynchronous</a></li>
111
+
112
+ <li><a href="../Journeta/Common.html">Journeta::Common</a></li>
113
+
114
+ <li><a href="../Journeta/Common/BasicMessage.html">Journeta::Common::BasicMessage</a></li>
115
+
116
+ <li><a href="../Journeta/Common/DummyPeerHandler.html">Journeta::Common::DummyPeerHandler</a></li>
117
+
118
+ <li><a href="../Journeta/Common/Job.html">Journeta::Common::Job</a></li>
119
+
120
+ <li><a href="../Journeta/Common/Shutdown.html">Journeta::Common::Shutdown</a></li>
121
+
122
+ <li><a href="../Journeta/DefaultPeerHandler.html">Journeta::DefaultPeerHandler</a></li>
123
+
124
+ <li><a href="../Journeta/DefaultPeerRegisteredHandler.html">Journeta::DefaultPeerRegisteredHandler</a></li>
125
+
126
+ <li><a href="../Journeta/DefaultPeerUnregisteredHandler.html">Journeta::DefaultPeerUnregisteredHandler</a></li>
127
+
128
+ <li><a href="../Journeta/DefaultPeerUpdatedHandler.html">Journeta::DefaultPeerUpdatedHandler</a></li>
129
+
130
+ <li><a href="../Journeta/Engine.html">Journeta::Engine</a></li>
131
+
132
+ <li><a href="../Journeta/Logger.html">Journeta::Logger</a></li>
133
+
134
+ <li><a href="../Journeta/NotImplementedException.html">Journeta::NotImplementedException</a></li>
135
+
136
+ <li><a href="../Journeta/PeerConnection.html">Journeta::PeerConnection</a></li>
137
+
138
+ <li><a href="../Journeta/PeerListener.html">Journeta::PeerListener</a></li>
139
+
140
+ <li><a href="../Journeta/PeerRegistry.html">Journeta::PeerRegistry</a></li>
141
+
142
+ <li><a href="../Journeta/PresenceBroadcaster.html">Journeta::PresenceBroadcaster</a></li>
143
+
144
+ <li><a href="../Journeta/PresenceListener.html">Journeta::PresenceListener</a></li>
145
+
146
+ <li><a href="../Journeta/PresenceMessage.html">Journeta::PresenceMessage</a></li>
147
+
148
+ <li><a href="../Array.html">Array</a></li>
149
+
150
+ <li><a href="../Diff.html">Diff</a></li>
151
+
152
+ <li><a href="../Diffable.html">Diffable</a></li>
153
+
154
+ <li><a href="../String.html">String</a></li>
155
+
156
+ </ul>
157
+ <div id="no-class-search-results" style="display: none;">No matching classes.</div>
158
+ </div>
159
+
160
+
161
+ </div>
162
+ </div>
163
+
164
+ <div id="documentation">
165
+ <h1 class="class">Journeta::PeerListener</h1>
166
+
167
+ <div id="description">
168
+ <p>
169
+ Accepts inbound connections from other peers using TCP. After the peer
170
+ finishes sending data, the connection is terminated. No data is returned to
171
+ the sender.
172
+ </p>
173
+
174
+ </div>
175
+
176
+ <!-- Constants -->
177
+
178
+
179
+ <!-- Attributes -->
180
+
181
+
182
+ <!-- Methods -->
183
+
184
+ <div id="public-instance-method-details" class="method-section section">
185
+ <h3 class="section-header">Public Instance Methods</h3>
186
+
187
+
188
+ <div id="go-method" class="method-detail ">
189
+ <a name="method-i-go"></a>
190
+
191
+ <div class="method-heading">
192
+
193
+ <span class="method-name">go</span><span
194
+ class="method-args">()</span>
195
+ <span class="method-click-advice">click to toggle source</span>
196
+
197
+ </div>
198
+
199
+ <div class="method-description">
200
+
201
+
202
+
203
+
204
+
205
+ <div class="method-source-code"
206
+ id="go-source">
207
+ <pre>
208
+ <span class="ruby-comment cmt"># File lib/journeta/peer_listener.rb, line 14</span>
209
+ 14: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">go</span>
210
+ 15: <span class="ruby-keyword kw">begin</span>
211
+ 16: <span class="ruby-comment cmt"># Grab configuration information from the injected object.</span>
212
+ 17: <span class="ruby-identifier">port</span> = <span class="ruby-ivar">@engine</span>.<span class="ruby-identifier">peer_port</span>
213
+ 18: <span class="ruby-identifier">socket</span> = <span class="ruby-constant">TCPServer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">port</span>)
214
+ 19: <span class="ruby-identifier">putsd</span> <span class="ruby-node">&quot;Listening on port #{port}&quot;</span>
215
+ 20:
216
+ 21: <span class="ruby-keyword kw">begin</span>
217
+ 22: <span class="ruby-identifier">loop</span> <span class="ruby-keyword kw">do</span>
218
+ 23:
219
+ 24: <span class="ruby-identifier">session</span> = <span class="ruby-identifier">socket</span>.<span class="ruby-identifier">accept</span>
220
+ 25: <span class="ruby-comment cmt"># We'll put the actual handling of the new session in the background so we </span>
221
+ 26: <span class="ruby-comment cmt"># can continue listening for new connections as soon as possible.</span>
222
+ 27: <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">session</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">session</span><span class="ruby-operator">|</span>
223
+ 28: <span class="ruby-identifier">data</span> = <span class="ruby-value str">''</span>
224
+ 29: <span class="ruby-comment cmt"># Read every last bit from the socket before passing off to the handler.</span>
225
+ 30: <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">more</span> = <span class="ruby-identifier">session</span>.<span class="ruby-identifier">gets</span>
226
+ 31: <span class="ruby-identifier">data</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">more</span>
227
+ 32: <span class="ruby-keyword kw">end</span>
228
+ 33: <span class="ruby-keyword kw">begin</span>
229
+ 34: <span class="ruby-identifier">msg</span> = <span class="ruby-constant">YAML</span><span class="ruby-operator">::</span><span class="ruby-identifier">load</span>(<span class="ruby-identifier">data</span>)
230
+ 35: <span class="ruby-identifier">h</span> = <span class="ruby-ivar">@engine</span>.<span class="ruby-identifier">peer_handler</span>
231
+ 36: <span class="ruby-identifier">h</span>.<span class="ruby-identifier">call</span> <span class="ruby-identifier">msg</span>
232
+ 37: <span class="ruby-keyword kw">rescue</span>
233
+ 38: <span class="ruby-identifier">putsd</span> <span class="ruby-value str">&quot;YAML could not be deserialized! The data will not be passed up to the application.&quot;</span>
234
+ 39: <span class="ruby-keyword kw">end</span>
235
+ 40: <span class="ruby-keyword kw">end</span>
236
+ 41: <span class="ruby-keyword kw">end</span>
237
+ 42: <span class="ruby-keyword kw">rescue</span>
238
+ 43: <span class="ruby-identifier">putsd</span> <span class="ruby-value str">&quot;Session closed.&quot;</span>
239
+ 44: <span class="ruby-keyword kw">end</span>
240
+ 45: <span class="ruby-keyword kw">ensure</span>
241
+ 46: <span class="ruby-identifier">putsd</span> <span class="ruby-value str">&quot;Closing peer listener socket.&quot;</span>
242
+ 47: <span class="ruby-comment cmt"># session.close</span>
243
+ 48: <span class="ruby-comment cmt"># socket.close</span>
244
+ 49: <span class="ruby-keyword kw">end</span>
245
+ 50: <span class="ruby-keyword kw">end</span></pre>
246
+ </div>
247
+
248
+ </div>
249
+
250
+
251
+
252
+
253
+ </div>
254
+
255
+
256
+ </div>
257
+
258
+
259
+ </div>
260
+
261
+
262
+ <div id="rdoc-debugging-section-dump" class="debugging-section">
263
+
264
+ <p>Disabled; run with --debug to generate this.</p>
265
+
266
+ </div>
267
+
268
+ <div id="validator-badges">
269
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
270
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
271
+ Rdoc Generator</a> 1.1.6</small>.</p>
272
+ </div>
273
+
274
+ </body>
275
+ </html>
276
+
@@ -0,0 +1,804 @@
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::PeerRegistry</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/peer_registry_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
42
+ class="thickbox" title="lib/journeta/peer_registry.rb">lib/journeta/peer_registry.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"><a href="Asynchronous.html">Journeta::Asynchronous</a></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-all">#all</a></li>
75
+
76
+ <li><a href="#method-i-all_do">#all_do</a></li>
77
+
78
+ <li><a href="#method-i-clear">#clear</a></li>
79
+
80
+ <li><a href="#method-i-go">#go</a></li>
81
+
82
+ <li><a href="#method-i-register">#register</a></li>
83
+
84
+ <li><a href="#method-i-send_peer_registered">#send_peer_registered</a></li>
85
+
86
+ <li><a href="#method-i-send_peer_unregistered">#send_peer_unregistered</a></li>
87
+
88
+ <li><a href="#method-i-send_peer_updated">#send_peer_updated</a></li>
89
+
90
+ <li><a href="#method-i-send_to_known_peers">#send_to_known_peers</a></li>
91
+
92
+ <li><a href="#method-i-send_to_peer">#send_to_peer</a></li>
93
+
94
+ <li><a href="#method-i-unregister">#unregister</a></li>
95
+
96
+ <li><a href="#method-i-unregister_all">#unregister_all</a></li>
97
+
98
+ </ul>
99
+ </div>
100
+
101
+
102
+ <!-- Included Modules -->
103
+
104
+ <div id="includes-section" class="section">
105
+ <h3 class="section-header">Included Modules</h3>
106
+ <ul class="link-list">
107
+
108
+
109
+ <li><span class="include">Logger</span></li>
110
+
111
+
112
+ </ul>
113
+ </div>
114
+
115
+ </div>
116
+
117
+ <div id="project-metadata">
118
+
119
+
120
+ <div id="fileindex-section" class="section project-section">
121
+ <h3 class="section-header">Files</h3>
122
+ <ul>
123
+
124
+ <li class="file"><a href="../README_rdoc.html">README.rdoc</a></li>
125
+
126
+ </ul>
127
+ </div>
128
+
129
+
130
+ <div id="classindex-section" class="section project-section">
131
+ <h3 class="section-header">Class Index
132
+ <span class="search-toggle"><img src="../images/find.png"
133
+ height="16" width="16" alt="[+]"
134
+ title="show/hide quicksearch" /></span></h3>
135
+ <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
136
+ <fieldset>
137
+ <legend>Quicksearch</legend>
138
+ <input type="text" name="quicksearch" value=""
139
+ class="quicksearch-field" />
140
+ </fieldset>
141
+ </form>
142
+
143
+ <ul class="link-list">
144
+
145
+ <li><a href="../Journeta/Asynchronous.html">Journeta::Asynchronous</a></li>
146
+
147
+ <li><a href="../Journeta/Common.html">Journeta::Common</a></li>
148
+
149
+ <li><a href="../Journeta/Common/BasicMessage.html">Journeta::Common::BasicMessage</a></li>
150
+
151
+ <li><a href="../Journeta/Common/DummyPeerHandler.html">Journeta::Common::DummyPeerHandler</a></li>
152
+
153
+ <li><a href="../Journeta/Common/Job.html">Journeta::Common::Job</a></li>
154
+
155
+ <li><a href="../Journeta/Common/Shutdown.html">Journeta::Common::Shutdown</a></li>
156
+
157
+ <li><a href="../Journeta/DefaultPeerHandler.html">Journeta::DefaultPeerHandler</a></li>
158
+
159
+ <li><a href="../Journeta/DefaultPeerRegisteredHandler.html">Journeta::DefaultPeerRegisteredHandler</a></li>
160
+
161
+ <li><a href="../Journeta/DefaultPeerUnregisteredHandler.html">Journeta::DefaultPeerUnregisteredHandler</a></li>
162
+
163
+ <li><a href="../Journeta/DefaultPeerUpdatedHandler.html">Journeta::DefaultPeerUpdatedHandler</a></li>
164
+
165
+ <li><a href="../Journeta/Engine.html">Journeta::Engine</a></li>
166
+
167
+ <li><a href="../Journeta/Logger.html">Journeta::Logger</a></li>
168
+
169
+ <li><a href="../Journeta/NotImplementedException.html">Journeta::NotImplementedException</a></li>
170
+
171
+ <li><a href="../Journeta/PeerConnection.html">Journeta::PeerConnection</a></li>
172
+
173
+ <li><a href="../Journeta/PeerListener.html">Journeta::PeerListener</a></li>
174
+
175
+ <li><a href="../Journeta/PeerRegistry.html">Journeta::PeerRegistry</a></li>
176
+
177
+ <li><a href="../Journeta/PresenceBroadcaster.html">Journeta::PresenceBroadcaster</a></li>
178
+
179
+ <li><a href="../Journeta/PresenceListener.html">Journeta::PresenceListener</a></li>
180
+
181
+ <li><a href="../Journeta/PresenceMessage.html">Journeta::PresenceMessage</a></li>
182
+
183
+ <li><a href="../Array.html">Array</a></li>
184
+
185
+ <li><a href="../Diff.html">Diff</a></li>
186
+
187
+ <li><a href="../Diffable.html">Diffable</a></li>
188
+
189
+ <li><a href="../String.html">String</a></li>
190
+
191
+ </ul>
192
+ <div id="no-class-search-results" style="display: none;">No matching classes.</div>
193
+ </div>
194
+
195
+
196
+ </div>
197
+ </div>
198
+
199
+ <div id="documentation">
200
+ <h1 class="class">Journeta::PeerRegistry</h1>
201
+
202
+ <div id="description">
203
+ <p>
204
+ Responsible for keeping in-memory metadata on known peers in the form of
205
+ PeerConnections.
206
+ </p>
207
+
208
+ </div>
209
+
210
+ <!-- Constants -->
211
+
212
+
213
+ <!-- Attributes -->
214
+
215
+
216
+ <!-- Methods -->
217
+
218
+ <div id="public-class-method-details" class="method-section section">
219
+ <h3 class="section-header">Public Class Methods</h3>
220
+
221
+
222
+ <div id="new-method" class="method-detail ">
223
+ <a name="method-c-new"></a>
224
+
225
+ <div class="method-heading">
226
+
227
+ <span class="method-name">new</span><span
228
+ class="method-args">(engine)</span>
229
+ <span class="method-click-advice">click to toggle source</span>
230
+
231
+ </div>
232
+
233
+ <div class="method-description">
234
+
235
+
236
+
237
+
238
+
239
+ <div class="method-source-code"
240
+ id="new-source">
241
+ <pre>
242
+ <span class="ruby-comment cmt"># File lib/journeta/peer_registry.rb, line 23</span>
243
+ 23: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">engine</span>)
244
+ 24: <span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">engine</span>)
245
+ 25: <span class="ruby-ivar">@peers</span> = {}
246
+ 26: <span class="ruby-ivar">@mutex</span> = <span class="ruby-constant">Mutex</span>.<span class="ruby-identifier">new</span>
247
+ 27: <span class="ruby-ivar">@reaper_period</span> = <span class="ruby-identifier">@@DEFAULT_REAPER_PERIOD</span>
248
+ 28: <span class="ruby-ivar">@reaper_tolerance</span> = <span class="ruby-identifier">engine</span>.<span class="ruby-identifier">presence_period</span> <span class="ruby-operator">+</span> <span class="ruby-value">2.0</span>
249
+ 29: <span class="ruby-keyword kw">end</span></pre>
250
+ </div>
251
+
252
+ </div>
253
+
254
+
255
+
256
+
257
+ </div>
258
+
259
+
260
+ </div>
261
+
262
+ <div id="public-instance-method-details" class="method-section section">
263
+ <h3 class="section-header">Public Instance Methods</h3>
264
+
265
+
266
+ <div id="all-method" class="method-detail ">
267
+ <a name="method-i-all"></a>
268
+
269
+ <div class="method-heading">
270
+
271
+ <span class="method-name">all</span><span
272
+ class="method-args">(all_groups = false)</span>
273
+ <span class="method-click-advice">click to toggle source</span>
274
+
275
+ </div>
276
+
277
+ <div class="method-description">
278
+
279
+
280
+
281
+
282
+
283
+ <div class="method-source-code"
284
+ id="all-source">
285
+ <pre>
286
+ <span class="ruby-comment cmt"># File lib/journeta/peer_registry.rb, line 58</span>
287
+ 58: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">all</span>(<span class="ruby-identifier">all_groups</span> = <span class="ruby-keyword kw">false</span>)
288
+ 59: <span class="ruby-identifier">r</span> = <span class="ruby-keyword kw">nil</span>
289
+ 60: <span class="ruby-ivar">@mutex</span>.<span class="ruby-identifier">synchronize</span> <span class="ruby-keyword kw">do</span>
290
+ 61: <span class="ruby-identifier">r</span> = <span class="ruby-identifier">all_do</span>(<span class="ruby-identifier">all_groups</span>)
291
+ 62: <span class="ruby-keyword kw">end</span>
292
+ 63: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">r</span>
293
+ 64: <span class="ruby-keyword kw">end</span></pre>
294
+ </div>
295
+
296
+ </div>
297
+
298
+
299
+
300
+
301
+ </div>
302
+
303
+
304
+ <div id="clear-method" class="method-detail ">
305
+ <a name="method-i-clear"></a>
306
+
307
+ <div class="method-heading">
308
+
309
+ <span class="method-name">clear</span><span
310
+ class="method-args">()</span>
311
+ <span class="method-click-advice">click to toggle source</span>
312
+
313
+ </div>
314
+
315
+ <div class="method-description">
316
+
317
+
318
+
319
+
320
+
321
+ <div class="method-source-code"
322
+ id="clear-source">
323
+ <pre>
324
+ <span class="ruby-comment cmt"># File lib/journeta/peer_registry.rb, line 31</span>
325
+ 31: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">clear</span>
326
+ 32: <span class="ruby-ivar">@mutex</span>.<span class="ruby-identifier">synchronize</span> <span class="ruby-keyword kw">do</span>
327
+ 33: <span class="ruby-identifier">h</span>.<span class="ruby-identifier">clear</span>
328
+ 34: <span class="ruby-keyword kw">end</span>
329
+ 35: <span class="ruby-keyword kw">end</span></pre>
330
+ </div>
331
+
332
+ </div>
333
+
334
+
335
+
336
+
337
+ </div>
338
+
339
+
340
+ <div id="go-method" class="method-detail ">
341
+ <a name="method-i-go"></a>
342
+
343
+ <div class="method-heading">
344
+
345
+ <span class="method-name">go</span><span
346
+ class="method-args">()</span>
347
+ <span class="method-click-advice">click to toggle source</span>
348
+
349
+ </div>
350
+
351
+ <div class="method-description">
352
+
353
+
354
+
355
+
356
+
357
+ <div class="method-source-code"
358
+ id="go-source">
359
+ <pre>
360
+ <span class="ruby-comment cmt"># File lib/journeta/peer_registry.rb, line 37</span>
361
+ 37: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">go</span>
362
+ 38: <span class="ruby-identifier">loop</span> <span class="ruby-keyword kw">do</span>
363
+ 39: <span class="ruby-ivar">@mutex</span>.<span class="ruby-identifier">synchronize</span> <span class="ruby-keyword kw">do</span>
364
+ 40: <span class="ruby-identifier">to_reap</span> = []
365
+ 41: <span class="ruby-ivar">@peers</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>
366
+ 42: <span class="ruby-identifier">tolerance</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span> <span class="ruby-operator">-</span> <span class="ruby-ivar">@reaper_tolerance</span>
367
+ 43: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">peer</span>.<span class="ruby-identifier">updated_at</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">tolerance</span>
368
+ 44: <span class="ruby-identifier">to_reap</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">peer</span>
369
+ 45: <span class="ruby-keyword kw">end</span>
370
+ 46: <span class="ruby-keyword kw">end</span>
371
+ 47: <span class="ruby-identifier">to_reap</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">peer</span><span class="ruby-operator">|</span>
372
+ 48: <span class="ruby-identifier">peer</span>.<span class="ruby-identifier">stop</span>
373
+ 49: <span class="ruby-ivar">@peers</span>.<span class="ruby-identifier">delete</span> <span class="ruby-identifier">peer</span>.<span class="ruby-identifier">uuid</span>
374
+ 50: <span class="ruby-identifier">send_peer_unregistered</span>(<span class="ruby-identifier">peer</span>)
375
+ 51: <span class="ruby-keyword kw">end</span>
376
+ 52: <span class="ruby-keyword kw">end</span>
377
+ 53: <span class="ruby-identifier">sleep</span> <span class="ruby-ivar">@reaper_period</span>
378
+ 54: <span class="ruby-keyword kw">end</span>
379
+ 55: <span class="ruby-keyword kw">end</span></pre>
380
+ </div>
381
+
382
+ </div>
383
+
384
+
385
+
386
+
387
+ </div>
388
+
389
+
390
+ <div id="register-method" class="method-detail ">
391
+ <a name="method-i-register"></a>
392
+
393
+ <div class="method-heading">
394
+
395
+ <span class="method-name">register</span><span
396
+ class="method-args">(peer)</span>
397
+ <span class="method-click-advice">click to toggle source</span>
398
+
399
+ </div>
400
+
401
+ <div class="method-description">
402
+
403
+ <p>
404
+ Adds a <tt>PeerConnection</tt> to the registry. It is optional but not
405
+ necessary to call +PeerConnection#start+ before manually adding it to the
406
+ registry! If a peer with the same UUID is already registered, the given
407
+ peer will be stopped and the existing one updated.
408
+ </p>
409
+
410
+
411
+
412
+ <div class="method-source-code"
413
+ id="register-source">
414
+ <pre>
415
+ <span class="ruby-comment cmt"># File lib/journeta/peer_registry.rb, line 68</span>
416
+ 68: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">register</span>(<span class="ruby-identifier">peer</span>)
417
+ 69: <span class="ruby-identifier">raise</span> <span class="ruby-value str">&quot;Do not try to register a nil peer!&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">peer</span>.<span class="ruby-identifier">nil?</span>
418
+ 70: <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;You can only add #{PeerConnection} instances to this registry, not #{peer.class}!&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">peer</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">PeerConnection</span>
419
+ 71: <span class="ruby-ivar">@mutex</span>.<span class="ruby-identifier">synchronize</span> <span class="ruby-keyword kw">do</span>
420
+ 72: <span class="ruby-comment cmt"># pp @peers</span>
421
+ 73: <span class="ruby-identifier">existing</span> = <span class="ruby-ivar">@peers</span>[<span class="ruby-identifier">peer</span>.<span class="ruby-identifier">uuid</span>]
422
+ 74: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">existing</span>.<span class="ruby-identifier">nil?</span>
423
+ 75: <span class="ruby-identifier">putsd</span> <span class="ruby-node">&quot;Adding peer #{peer.uuid}.&quot;</span>
424
+ 76: <span class="ruby-identifier">peer</span>.<span class="ruby-identifier">start</span>
425
+ 77: <span class="ruby-ivar">@peers</span>[<span class="ruby-identifier">peer</span>.<span class="ruby-identifier">uuid</span>] = <span class="ruby-identifier">peer</span>
426
+ 78: <span class="ruby-identifier">send_peer_registered</span>(<span class="ruby-identifier">peer</span>)
427
+ 79: <span class="ruby-keyword kw">else</span>
428
+ 80: <span class="ruby-identifier">putsd</span> <span class="ruby-node">&quot;Updating peer #{peer.uuid}.&quot;</span>
429
+ 81: <span class="ruby-identifier">peer</span>.<span class="ruby-identifier">stop</span>
430
+ 82: <span class="ruby-comment cmt"># Make sure we're not overriding the creation date of the original entry.</span>
431
+ 83: <span class="ruby-identifier">peer</span>.<span class="ruby-identifier">created_at</span> = <span class="ruby-keyword kw">nil</span>
432
+ 84: <span class="ruby-identifier">existing</span>.<span class="ruby-identifier">update_settings</span> <span class="ruby-identifier">peer</span>
433
+ 85: <span class="ruby-identifier">send_peer_updated</span>(<span class="ruby-identifier">existing</span>)
434
+ 86: <span class="ruby-keyword kw">end</span>
435
+ 87:
436
+ 88: <span class="ruby-keyword kw">end</span>
437
+ 89: <span class="ruby-keyword kw">end</span></pre>
438
+ </div>
439
+
440
+ </div>
441
+
442
+
443
+
444
+
445
+ </div>
446
+
447
+
448
+ <div id="send-peer-registered-method" class="method-detail ">
449
+ <a name="method-i-send_peer_registered"></a>
450
+
451
+ <div class="method-heading">
452
+
453
+ <span class="method-name">send_peer_registered</span><span
454
+ class="method-args">(peer)</span>
455
+ <span class="method-click-advice">click to toggle source</span>
456
+
457
+ </div>
458
+
459
+ <div class="method-description">
460
+
461
+
462
+
463
+
464
+
465
+ <div class="method-source-code"
466
+ id="send-peer-registered-source">
467
+ <pre>
468
+ <span class="ruby-comment cmt"># File lib/journeta/peer_registry.rb, line 137</span>
469
+ 137: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_peer_registered</span>(<span class="ruby-identifier">peer</span>)
470
+ 138: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">peer</span>.<span class="ruby-identifier">nil?</span>
471
+ 139: <span class="ruby-identifier">handler</span> = <span class="ruby-ivar">@engine</span>.<span class="ruby-identifier">peer_registered_handler</span>
472
+ 140: <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">handler</span>, <span class="ruby-identifier">peer</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">h</span>, <span class="ruby-identifier">peer</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">peer</span>)}
473
+ 141: <span class="ruby-keyword kw">end</span></pre>
474
+ </div>
475
+
476
+ </div>
477
+
478
+
479
+
480
+
481
+ </div>
482
+
483
+
484
+ <div id="send-peer-unregistered-method" class="method-detail ">
485
+ <a name="method-i-send_peer_unregistered"></a>
486
+
487
+ <div class="method-heading">
488
+
489
+ <span class="method-name">send_peer_unregistered</span><span
490
+ class="method-args">(peer)</span>
491
+ <span class="method-click-advice">click to toggle source</span>
492
+
493
+ </div>
494
+
495
+ <div class="method-description">
496
+
497
+
498
+
499
+
500
+
501
+ <div class="method-source-code"
502
+ id="send-peer-unregistered-source">
503
+ <pre>
504
+ <span class="ruby-comment cmt"># File lib/journeta/peer_registry.rb, line 149</span>
505
+ 149: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_peer_unregistered</span>(<span class="ruby-identifier">peer</span>)
506
+ 150: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">peer</span>.<span class="ruby-identifier">nil?</span>
507
+ 151: <span class="ruby-identifier">handler</span> = <span class="ruby-ivar">@engine</span>.<span class="ruby-identifier">peer_unregistered_handler</span>
508
+ 152: <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">handler</span>, <span class="ruby-identifier">peer</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">h</span>, <span class="ruby-identifier">peer</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">peer</span>)}
509
+ 153: <span class="ruby-keyword kw">end</span></pre>
510
+ </div>
511
+
512
+ </div>
513
+
514
+
515
+
516
+
517
+ </div>
518
+
519
+
520
+ <div id="send-peer-updated-method" class="method-detail ">
521
+ <a name="method-i-send_peer_updated"></a>
522
+
523
+ <div class="method-heading">
524
+
525
+ <span class="method-name">send_peer_updated</span><span
526
+ class="method-args">(peer)</span>
527
+ <span class="method-click-advice">click to toggle source</span>
528
+
529
+ </div>
530
+
531
+ <div class="method-description">
532
+
533
+
534
+
535
+
536
+
537
+ <div class="method-source-code"
538
+ id="send-peer-updated-source">
539
+ <pre>
540
+ <span class="ruby-comment cmt"># File lib/journeta/peer_registry.rb, line 143</span>
541
+ 143: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_peer_updated</span>(<span class="ruby-identifier">peer</span>)
542
+ 144: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">peer</span>.<span class="ruby-identifier">nil?</span>
543
+ 145: <span class="ruby-identifier">handler</span> = <span class="ruby-ivar">@engine</span>.<span class="ruby-identifier">peer_updated_handler</span>
544
+ 146: <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">handler</span>, <span class="ruby-identifier">peer</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">h</span>, <span class="ruby-identifier">peer</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">peer</span>)}
545
+ 147: <span class="ruby-keyword kw">end</span></pre>
546
+ </div>
547
+
548
+ </div>
549
+
550
+
551
+
552
+
553
+ </div>
554
+
555
+
556
+ <div id="send-to-known-peers-method" class="method-detail ">
557
+ <a name="method-i-send_to_known_peers"></a>
558
+
559
+ <div class="method-heading">
560
+
561
+ <span class="method-name">send_to_known_peers</span><span
562
+ class="method-args">(payload)</span>
563
+ <span class="method-click-advice">click to toggle source</span>
564
+
565
+ </div>
566
+
567
+ <div class="method-description">
568
+
569
+
570
+
571
+
572
+
573
+ <div class="method-source-code"
574
+ id="send-to-known-peers-source">
575
+ <pre>
576
+ <span class="ruby-comment cmt"># File lib/journeta/peer_registry.rb, line 102</span>
577
+ 102: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_to_known_peers</span>(<span class="ruby-identifier">payload</span>)
578
+ 103: <span class="ruby-comment cmt"># Iterate over each currently known peer and stuff the payload into each peers outgoing data queue.</span>
579
+ 104: <span class="ruby-ivar">@mutex</span>.<span class="ruby-identifier">synchronize</span> <span class="ruby-keyword kw">do</span>
580
+ 105: <span class="ruby-comment cmt"># Grab all peers in relevant groups.</span>
581
+ 106: <span class="ruby-identifier">group</span> = <span class="ruby-identifier">all_do</span>
582
+ 107: <span class="ruby-identifier">n</span>= <span class="ruby-identifier">group</span>.<span class="ruby-identifier">length</span>
583
+ 108: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">n</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
584
+ 109: <span class="ruby-identifier">putsd</span> <span class="ruby-node">&quot;Sending payload to #{n} peers.&quot;</span>
585
+ 110: <span class="ruby-identifier">group</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">conn</span><span class="ruby-operator">|</span>
586
+ 111: <span class="ruby-identifier">conn</span>.<span class="ruby-identifier">send_payload</span> <span class="ruby-identifier">payload</span>
587
+ 112: <span class="ruby-keyword kw">end</span>
588
+ 113: <span class="ruby-keyword kw">else</span>
589
+ 114: <span class="ruby-identifier">putsd</span> <span class="ruby-value str">'No peers (in relevant groups) to send message to!'</span>
590
+ 115: <span class="ruby-keyword kw">end</span>
591
+ 116: <span class="ruby-keyword kw">end</span>
592
+ 117: <span class="ruby-keyword kw">end</span></pre>
593
+ </div>
594
+
595
+ </div>
596
+
597
+
598
+
599
+
600
+ </div>
601
+
602
+
603
+ <div id="send-to-peer-method" class="method-detail ">
604
+ <a name="method-i-send_to_peer"></a>
605
+
606
+ <div class="method-heading">
607
+
608
+ <span class="method-name">send_to_peer</span><span
609
+ class="method-args">(uuid, payload)</span>
610
+ <span class="method-click-advice">click to toggle source</span>
611
+
612
+ </div>
613
+
614
+ <div class="method-description">
615
+
616
+
617
+
618
+
619
+
620
+ <div class="method-source-code"
621
+ id="send-to-peer-source">
622
+ <pre>
623
+ <span class="ruby-comment cmt"># File lib/journeta/peer_registry.rb, line 128</span>
624
+ 128: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_to_peer</span>(<span class="ruby-identifier">uuid</span>, <span class="ruby-identifier">payload</span>)
625
+ 129: <span class="ruby-ivar">@mutex</span>.<span class="ruby-identifier">synchronize</span> <span class="ruby-keyword kw">do</span>
626
+ 130: <span class="ruby-identifier">p</span> = <span class="ruby-ivar">@peers</span>[<span class="ruby-identifier">uuid</span>]
627
+ 131: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">p</span>
628
+ 132: <span class="ruby-identifier">p</span>.<span class="ruby-identifier">send_payload</span>(<span class="ruby-identifier">payload</span>)
629
+ 133: <span class="ruby-keyword kw">end</span>
630
+ 134: <span class="ruby-keyword kw">end</span>
631
+ 135: <span class="ruby-keyword kw">end</span></pre>
632
+ </div>
633
+
634
+ </div>
635
+
636
+
637
+
638
+
639
+ </div>
640
+
641
+
642
+ <div id="unregister-method" class="method-detail ">
643
+ <a name="method-i-unregister"></a>
644
+
645
+ <div class="method-heading">
646
+
647
+ <span class="method-name">unregister</span><span
648
+ class="method-args">(peer)</span>
649
+ <span class="method-click-advice">click to toggle source</span>
650
+
651
+ </div>
652
+
653
+ <div class="method-description">
654
+
655
+ <p>
656
+ Removes a <tt>PeerConnection</tt> from the registry. If the peer is still
657
+ broadcasting presence, it will magically become reregistered at some point!
658
+ </p>
659
+
660
+
661
+
662
+ <div class="method-source-code"
663
+ id="unregister-source">
664
+ <pre>
665
+ <span class="ruby-comment cmt"># File lib/journeta/peer_registry.rb, line 92</span>
666
+ 92: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unregister</span>(<span class="ruby-identifier">peer</span>)
667
+ 93: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-operator">!</span><span class="ruby-identifier">peer</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">peer</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">PeerConnection</span>
668
+ 94: <span class="ruby-ivar">@mutex</span>.<span class="ruby-identifier">synchronize</span> <span class="ruby-keyword kw">do</span>
669
+ 95: <span class="ruby-identifier">peer</span>.<span class="ruby-identifier">stop</span>
670
+ 96: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">peer</span>.<span class="ruby-identifier">uuid</span>
671
+ 97: <span class="ruby-ivar">@peers</span>.<span class="ruby-identifier">delete</span> <span class="ruby-identifier">peer</span>.<span class="ruby-identifier">uuid</span>
672
+ 98: <span class="ruby-keyword kw">end</span>
673
+ 99: <span class="ruby-keyword kw">end</span>
674
+ 100: <span class="ruby-keyword kw">end</span></pre>
675
+ </div>
676
+
677
+ </div>
678
+
679
+
680
+
681
+
682
+ </div>
683
+
684
+
685
+ <div id="unregister-all-method" class="method-detail ">
686
+ <a name="method-i-unregister_all"></a>
687
+
688
+ <div class="method-heading">
689
+
690
+ <span class="method-name">unregister_all</span><span
691
+ class="method-args">()</span>
692
+ <span class="method-click-advice">click to toggle source</span>
693
+
694
+ </div>
695
+
696
+ <div class="method-description">
697
+
698
+ <p>
699
+ Destroys all active connections.
700
+ </p>
701
+
702
+
703
+
704
+ <div class="method-source-code"
705
+ id="unregister-all-source">
706
+ <pre>
707
+ <span class="ruby-comment cmt"># File lib/journeta/peer_registry.rb, line 120</span>
708
+ 120: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unregister_all</span>
709
+ 121: <span class="ruby-ivar">@mutex</span>.<span class="ruby-identifier">synchronize</span> <span class="ruby-keyword kw">do</span>
710
+ 122: <span class="ruby-ivar">@peers</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">n</span><span class="ruby-operator">|</span>
711
+ 123: <span class="ruby-identifier">n</span>.<span class="ruby-identifier">stop</span>
712
+ 124: <span class="ruby-keyword kw">end</span>
713
+ 125: <span class="ruby-keyword kw">end</span>
714
+ 126: <span class="ruby-keyword kw">end</span></pre>
715
+ </div>
716
+
717
+ </div>
718
+
719
+
720
+
721
+
722
+ </div>
723
+
724
+
725
+ </div>
726
+
727
+ <div id="protected-instance-method-details" class="method-section section">
728
+ <h3 class="section-header">Protected Instance Methods</h3>
729
+
730
+
731
+ <div id="all-do-method" class="method-detail ">
732
+ <a name="method-i-all_do"></a>
733
+
734
+ <div class="method-heading">
735
+
736
+ <span class="method-name">all_do</span><span
737
+ class="method-args">(all_groups = false)</span>
738
+ <span class="method-click-advice">click to toggle source</span>
739
+
740
+ </div>
741
+
742
+ <div class="method-description">
743
+
744
+
745
+
746
+
747
+
748
+ <div class="method-source-code"
749
+ id="all-do-source">
750
+ <pre>
751
+ <span class="ruby-comment cmt"># File lib/journeta/peer_registry.rb, line 157</span>
752
+ 157: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">all_do</span>(<span class="ruby-identifier">all_groups</span> = <span class="ruby-keyword kw">false</span>)
753
+ 158: <span class="ruby-identifier">res</span> = <span class="ruby-keyword kw">nil</span>
754
+ 159: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">all_groups</span>
755
+ 160: <span class="ruby-comment cmt"># Create a new structure to avoid corruption of the original.</span>
756
+ 161: <span class="ruby-identifier">res</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">update</span> <span class="ruby-ivar">@peers</span>
757
+ 162: <span class="ruby-keyword kw">else</span>
758
+ 163: <span class="ruby-identifier">res</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
759
+ 164: <span class="ruby-ivar">@peers</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>
760
+ 165: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">peer</span>.<span class="ruby-identifier">groups</span>
761
+ 166: <span class="ruby-identifier">peer</span>.<span class="ruby-identifier">groups</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">g</span><span class="ruby-operator">|</span>
762
+ 167: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@engine</span>.<span class="ruby-identifier">groups</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-ivar">@engine</span>.<span class="ruby-identifier">groups</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">g</span>)
763
+ 168: <span class="ruby-identifier">res</span>[<span class="ruby-identifier">uuid</span>] = <span class="ruby-identifier">peer</span>
764
+ 169: <span class="ruby-keyword kw">end</span>
765
+ 170: <span class="ruby-keyword kw">end</span>
766
+ 171: <span class="ruby-keyword kw">else</span>
767
+ 172: <span class="ruby-comment cmt"># Peer is a member of all groups.</span>
768
+ 173: <span class="ruby-identifier">res</span>[<span class="ruby-identifier">uuid</span>] = <span class="ruby-identifier">peer</span>
769
+ 174: <span class="ruby-keyword kw">end</span>
770
+ 175: <span class="ruby-keyword kw">end</span>
771
+ 176: <span class="ruby-keyword kw">end</span>
772
+ 177: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">res</span>
773
+ 178: <span class="ruby-keyword kw">end</span></pre>
774
+ </div>
775
+
776
+ </div>
777
+
778
+
779
+
780
+
781
+ </div>
782
+
783
+
784
+ </div>
785
+
786
+
787
+ </div>
788
+
789
+
790
+ <div id="rdoc-debugging-section-dump" class="debugging-section">
791
+
792
+ <p>Disabled; run with --debug to generate this.</p>
793
+
794
+ </div>
795
+
796
+ <div id="validator-badges">
797
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
798
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
799
+ Rdoc Generator</a> 1.1.6</small>.</p>
800
+ </div>
801
+
802
+ </body>
803
+ </html>
804
+