bridge-ruby 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. data/LICENSE +19 -0
  2. data/README.md +31 -0
  3. data/Rakefile +24 -0
  4. data/bridge-ruby.gemspec +24 -0
  5. data/doc/Bridge.html +276 -0
  6. data/doc/Bridge/Bridge.html +1874 -0
  7. data/doc/Bridge/Bridge/SystemService.html +396 -0
  8. data/doc/Bridge/Client.html +271 -0
  9. data/doc/Bridge/Connection.html +1180 -0
  10. data/doc/Bridge/Connection/SockBuffer.html +322 -0
  11. data/doc/Bridge/Reference.html +605 -0
  12. data/doc/Bridge/Serializer.html +405 -0
  13. data/doc/Bridge/Serializer/Callback.html +498 -0
  14. data/doc/Bridge/Tcp.html +657 -0
  15. data/doc/Bridge/Util.html +643 -0
  16. data/doc/Bridge/Util/CallbackReference.html +557 -0
  17. data/doc/OpenSSL/X509/Certificate.html +275 -0
  18. data/doc/SSLCertificateVerification.html +446 -0
  19. data/doc/_index.html +239 -0
  20. data/doc/class_list.html +53 -0
  21. data/doc/css/common.css +1 -0
  22. data/doc/css/full_list.css +57 -0
  23. data/doc/css/style.css +328 -0
  24. data/doc/file.README.html +106 -0
  25. data/doc/file_list.html +55 -0
  26. data/doc/frames.html +28 -0
  27. data/doc/index.html +106 -0
  28. data/doc/js/app.js +214 -0
  29. data/doc/js/full_list.js +173 -0
  30. data/doc/js/jquery.js +4 -0
  31. data/doc/method_list.html +772 -0
  32. data/doc/top-level-namespace.html +112 -0
  33. data/examples/channels/client-writeable.rb +24 -0
  34. data/examples/channels/client.rb +23 -0
  35. data/examples/channels/server.rb +24 -0
  36. data/examples/chat/chatclient.rb +21 -0
  37. data/examples/chat/chatserver.rb +24 -0
  38. data/examples/client-context/client.rb +21 -0
  39. data/examples/client-context/server.rb +25 -0
  40. data/examples/secure/example.rb +8 -0
  41. data/examples/simple/channels.rb +47 -0
  42. data/examples/simple/services.rb +41 -0
  43. data/include/ssl/cacert.pem +3331 -0
  44. data/lib/bridge-ruby.rb +441 -0
  45. data/lib/client.rb +14 -0
  46. data/lib/connection.rb +162 -0
  47. data/lib/reference.rb +49 -0
  48. data/lib/serializer.rb +104 -0
  49. data/lib/ssl_utils.rb +68 -0
  50. data/lib/tcp.rb +73 -0
  51. data/lib/util.rb +101 -0
  52. data/lib/version.rb +3 -0
  53. data/rakelib/package.rake +4 -0
  54. data/rakelib/test.rake +8 -0
  55. data/test/regression/reconnect.rb +48 -0
  56. data/test/regression/rpc.rb +39 -0
  57. data/test/regression/test.rb +58 -0
  58. data/test/unit/bridge_dummy.rb +26 -0
  59. data/test/unit/connection_dummy.rb +21 -0
  60. data/test/unit/reference_dummy.rb +11 -0
  61. data/test/unit/tcp_dummy.rb +12 -0
  62. data/test/unit/test.rb +20 -0
  63. data/test/unit/test_reference.rb +30 -0
  64. data/test/unit/test_serializer.rb +109 -0
  65. data/test/unit/test_tcp.rb +51 -0
  66. data/test/unit/test_util.rb +59 -0
  67. metadata +162 -0
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2012 by Flotype Inc. <legal@getbridge.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,31 @@
1
+ # Bridge for Ruby
2
+ Bridge is a unified messaging system that allows you to easily build
3
+ cross-language services to share data and realtime updates among your
4
+ servers and your clients
5
+
6
+ ## Installation
7
+ Quick install: Using [RubyGems](https://rubygems.org/), do `gem install bridge-ruby --pre`
8
+
9
+ Source install:
10
+
11
+ Clone this repository using `git clone git@github.org:getbridge/bridge-ruby.git` and install using
12
+
13
+ $ cd bridge-ruby
14
+ $ rake && rake install
15
+
16
+ ### Dependencies
17
+ [EventMachine](http://rubyeventmachine.com/) for asynchronous event
18
+ loop.
19
+
20
+ ## Documentation and Support
21
+ * API Reference: http://getbridge.com/docs/api/ruby/
22
+ * Getting Started: http://www.getbridge.com/docs/gettingstarted/ruby/
23
+ * About Bridge: http://www.getbridge.com/
24
+
25
+ The `examples` directory of this library contains sample applications for Bridge.
26
+
27
+ Support is available in #getbridge on Freenode IRC or the Bridge Google Group.
28
+
29
+
30
+ ## License
31
+ Bridge is made available under the MIT/X11 license. See LICENSE file for details.
@@ -0,0 +1,24 @@
1
+ require 'rubygems'
2
+ require 'rubygems/installer'
3
+ GEMSPEC = Gem::Specification.load('bridge-ruby.gemspec')
4
+
5
+ require 'rake/clean'
6
+ task :clobber => :clean
7
+
8
+ desc "Build bridge, then run tests."
9
+ task :default => [:test, :package]
10
+
11
+ task :install => :package do
12
+ Gem::Installer.new("pkg/bridge-ruby-#{GEMSPEC.version}.gem").install
13
+ end
14
+
15
+ desc 'Generate documentation'
16
+ begin
17
+ require 'yard'
18
+ YARD::Rake::YardocTask.new do |t|
19
+ t.files = ['lib/**/*.rb', '-', 'docs/*.md']
20
+ t.options = ['--main', 'README.md', '--no-private']
21
+ end
22
+ rescue LoadError
23
+ task :yard do puts "Please install yard first!"; end
24
+ end
@@ -0,0 +1,24 @@
1
+ require File.expand_path('../lib/version', __FILE__)
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'bridge-ruby'
5
+ s.version = Bridge::VERSION
6
+ s.homepage = 'http://getbridge.com'
7
+
8
+ s.authors = [""]
9
+ s.email = ["team@getbridge.com"]
10
+
11
+ s.files = `git ls-files`.split("\n")
12
+
13
+ s.add_dependency 'eventmachine', '>= 0.12.0'
14
+ s.add_dependency 'json', ">= 1.5.0"
15
+
16
+ s.add_development_dependency 'yard', '>= 0.7.2'
17
+ s.add_development_dependency 'rake-compiler', '>= 0.7.9'
18
+
19
+ s.summary = 'Ruby/Bridge library'
20
+ s.description = "Bridge client for Ruby."
21
+
22
+ s.rdoc_options = ["--title", "Bridge", "--main", "README.md", "-x", "lib/version"]
23
+ s.extra_rdoc_files = ["README.md"] + `git ls-files -- docs/*`.split("\n")
24
+ end
@@ -0,0 +1,276 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Module: Bridge
8
+
9
+ &mdash; Documentation by YARD 0.8.2.1
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '';
20
+ framesUrl = "frames.html#!" + escape(window.location.href);
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="_index.html">Index (B)</a> &raquo;
35
+
36
+
37
+ <span class="title">Bridge</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Module: Bridge
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+ <dt class="r1 last">Defined in:</dt>
82
+ <dd class="r1 last">lib/bridge.rb<span class="defines">,<br />
83
+ lib/tcp.rb,<br /> lib/util.rb,<br /> lib/client.rb,<br /> lib/version.rb,<br /> lib/reference.rb,<br /> lib/serializer.rb,<br /> lib/connection.rb</span>
84
+ </dd>
85
+
86
+ </dl>
87
+ <div class="clear"></div>
88
+
89
+ <h2>Overview</h2><div class="docstring">
90
+ <div class="discussion">
91
+
92
+ <h2 id="label-Bridge">Bridge</h2>
93
+
94
+ <p>Bridge is a cross-language and platform framework for realtime
95
+ communication and RPC.</p>
96
+
97
+ <p>The Bridge ruby client is fully featured and has full compatibility with
98
+ all other Bridge clients.</p>
99
+
100
+ <p>Bridge::Bridge</p>
101
+
102
+
103
+ </div>
104
+ </div>
105
+ <div class="tags">
106
+
107
+
108
+ </div><h2>Defined Under Namespace</h2>
109
+ <p class="children">
110
+
111
+
112
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="Bridge/Serializer.html" title="Bridge::Serializer (module)">Serializer</a></span>, <span class='object_link'><a href="Bridge/Util.html" title="Bridge::Util (module)">Util</a></span>
113
+
114
+
115
+
116
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="Bridge/Bridge.html" title="Bridge::Bridge (class)">Bridge</a></span>, <span class='object_link'><a href="Bridge/Client.html" title="Bridge::Client (class)">Client</a></span>, <span class='object_link'><a href="Bridge/Connection.html" title="Bridge::Connection (class)">Connection</a></span>, <span class='object_link'><a href="Bridge/Reference.html" title="Bridge::Reference (class)">Reference</a></span>, <span class='object_link'><a href="Bridge/Tcp.html" title="Bridge::Tcp (class)">Tcp</a></span>
117
+
118
+
119
+ </p>
120
+
121
+ <h2>Constant Summary</h2>
122
+
123
+ <dl class="constants">
124
+
125
+ <dt id="VERSION-constant" class="">VERSION =
126
+
127
+ </dt>
128
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>0.2.0</span><span class='tstring_end'>&quot;</span></span></pre></dd>
129
+
130
+ <dt id="instance-classvariable" class="">@@instance =
131
+
132
+ </dt>
133
+ <dd><pre class="code"><span class='kw'>nil</span></pre></dd>
134
+
135
+ </dl>
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+
144
+
145
+ <h2>
146
+ Class Method Summary
147
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
148
+ </h2>
149
+
150
+ <ul class="summary">
151
+
152
+ <li class="public ">
153
+ <span class="summary_signature">
154
+
155
+ <a href="#instance-class_method" title="instance (class method)">+ (Object) <strong>instance</strong> </a>
156
+
157
+
158
+
159
+ </span>
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+ <span class="summary_desc"><div class='inline'></div></span>
170
+
171
+ </li>
172
+
173
+
174
+ <li class="public ">
175
+ <span class="summary_signature">
176
+
177
+ <a href="#instance%3D-class_method" title="instance= (class method)">+ (Object) <strong>instance=</strong>(i) </a>
178
+
179
+
180
+
181
+ </span>
182
+
183
+
184
+
185
+
186
+
187
+
188
+
189
+
190
+
191
+ <span class="summary_desc"><div class='inline'></div></span>
192
+
193
+ </li>
194
+
195
+
196
+ </ul>
197
+
198
+
199
+
200
+
201
+ <div id="class_method_details" class="method_details_list">
202
+ <h2>Class Method Details</h2>
203
+
204
+
205
+ <div class="method_details first">
206
+ <h3 class="signature first" id="instance-class_method">
207
+
208
+ + (<tt>Object</tt>) <strong>instance</strong>
209
+
210
+
211
+
212
+
213
+
214
+ </h3><table class="source_code">
215
+ <tr>
216
+ <td>
217
+ <pre class="lines">
218
+
219
+
220
+ 23
221
+ 24
222
+ 25</pre>
223
+ </td>
224
+ <td>
225
+ <pre class="code"><span class="info file"># File 'lib/bridge.rb', line 23</span>
226
+
227
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span>
228
+ <span class='cvar'>@@instance</span>
229
+ <span class='kw'>end</span></pre>
230
+ </td>
231
+ </tr>
232
+ </table>
233
+ </div>
234
+
235
+ <div class="method_details ">
236
+ <h3 class="signature " id="instance=-class_method">
237
+
238
+ + (<tt>Object</tt>) <strong>instance=</strong>(i)
239
+
240
+
241
+
242
+
243
+
244
+ </h3><table class="source_code">
245
+ <tr>
246
+ <td>
247
+ <pre class="lines">
248
+
249
+
250
+ 27
251
+ 28
252
+ 29</pre>
253
+ </td>
254
+ <td>
255
+ <pre class="code"><span class="info file"># File 'lib/bridge.rb', line 27</span>
256
+
257
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_instance='>instance=</span> <span class='id identifier rubyid_i'>i</span>
258
+ <span class='cvar'>@@instance</span> <span class='op'>=</span> <span class='id identifier rubyid_i'>i</span>
259
+ <span class='kw'>end</span></pre>
260
+ </td>
261
+ </tr>
262
+ </table>
263
+ </div>
264
+
265
+ </div>
266
+
267
+ </div>
268
+
269
+ <div id="footer">
270
+ Generated on Wed Jun 20 11:00:11 2012 by
271
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
272
+ 0.8.2.1 (ruby-1.9.3).
273
+ </div>
274
+
275
+ </body>
276
+ </html>
@@ -0,0 +1,1874 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Class: Bridge::Bridge
8
+
9
+ &mdash; Documentation by YARD 0.8.2.1
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" media="screen" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '../';
20
+ framesUrl = "../frames.html#!" + escape(window.location.href);
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="../_index.html">Index (B)</a> &raquo;
35
+ <span class='title'><span class='object_link'><a href="../Bridge.html" title="Bridge (module)">Bridge</a></span></span>
36
+ &raquo;
37
+ <span class="title">Bridge</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="../class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="../method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="../file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Class: Bridge::Bridge
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+ <dt class="r1">Inherits:</dt>
75
+ <dd class="r1">
76
+ <span class="inheritName">Object</span>
77
+
78
+ <ul class="fullTree">
79
+ <li>Object</li>
80
+
81
+ <li class="next">Bridge::Bridge</li>
82
+
83
+ </ul>
84
+ <a href="#" class="inheritanceTree">show all</a>
85
+
86
+ </dd>
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+ <dt class="r2 last">Defined in:</dt>
97
+ <dd class="r2 last">lib/bridge.rb</dd>
98
+
99
+ </dl>
100
+ <div class="clear"></div>
101
+
102
+ <h2>Defined Under Namespace</h2>
103
+ <p class="children">
104
+
105
+
106
+
107
+
108
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="Bridge/SystemService.html" title="Bridge::Bridge::SystemService (class)">SystemService</a></span>
109
+
110
+
111
+ </p>
112
+
113
+
114
+
115
+
116
+ <h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
117
+ <ul class="summary">
118
+
119
+ <li class="public ">
120
+ <span class="summary_signature">
121
+
122
+ <a href="#connection-instance_method" title="#connection (instance method)">- (Object) <strong>connection</strong> </a>
123
+
124
+
125
+
126
+ </span>
127
+
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+ <span class="summary_desc"><div class='inline'>
140
+ <p>:nodoc:.</p>
141
+ </div></span>
142
+
143
+ </li>
144
+
145
+
146
+ <li class="public ">
147
+ <span class="summary_signature">
148
+
149
+ <a href="#context-instance_method" title="#context (instance method)">- (Object) <strong>context</strong> </a>
150
+
151
+
152
+
153
+ </span>
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+ <span class="summary_desc"><div class='inline'>
167
+ <p>:nodoc:.</p>
168
+ </div></span>
169
+
170
+ </li>
171
+
172
+
173
+ <li class="public ">
174
+ <span class="summary_signature">
175
+
176
+ <a href="#is_ready-instance_method" title="#is_ready (instance method)">- (Object) <strong>is_ready</strong> </a>
177
+
178
+
179
+
180
+ </span>
181
+
182
+
183
+
184
+
185
+
186
+
187
+
188
+
189
+
190
+
191
+
192
+
193
+ <span class="summary_desc"><div class='inline'>
194
+ <p>:nodoc:.</p>
195
+ </div></span>
196
+
197
+ </li>
198
+
199
+
200
+ <li class="public ">
201
+ <span class="summary_signature">
202
+
203
+ <a href="#options-instance_method" title="#options (instance method)">- (Object) <strong>options</strong> </a>
204
+
205
+
206
+
207
+ </span>
208
+
209
+
210
+
211
+
212
+
213
+
214
+
215
+
216
+
217
+
218
+
219
+
220
+ <span class="summary_desc"><div class='inline'>
221
+ <p>:nodoc:.</p>
222
+ </div></span>
223
+
224
+ </li>
225
+
226
+
227
+ <li class="public ">
228
+ <span class="summary_signature">
229
+
230
+ <a href="#store-instance_method" title="#store (instance method)">- (Object) <strong>store</strong> </a>
231
+
232
+
233
+
234
+ </span>
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+ <span class="summary_desc"><div class='inline'>
248
+ <p>:nodoc:.</p>
249
+ </div></span>
250
+
251
+ </li>
252
+
253
+
254
+ </ul>
255
+
256
+
257
+
258
+
259
+
260
+ <h2>
261
+ Instance Method Summary
262
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
263
+ </h2>
264
+
265
+ <ul class="summary">
266
+
267
+ <li class="public ">
268
+ <span class="summary_signature">
269
+
270
+ <a href="#connect-instance_method" title="#connect (instance method)">- (Object) <strong>connect</strong>(&amp;callback) </a>
271
+
272
+
273
+
274
+ </span>
275
+
276
+
277
+
278
+
279
+
280
+
281
+
282
+
283
+
284
+ <span class="summary_desc"><div class='inline'>
285
+ <p>:call-seq:.</p>
286
+ </div></span>
287
+
288
+ </li>
289
+
290
+
291
+ <li class="public ">
292
+ <span class="summary_signature">
293
+
294
+ <a href="#emit-instance_method" title="#emit (instance method)">- (Object) <strong>emit</strong>(name, args = []) </a>
295
+
296
+
297
+
298
+ </span>
299
+
300
+
301
+
302
+
303
+
304
+
305
+
306
+
307
+
308
+ <span class="summary_desc"><div class='inline'>
309
+ <p>:nodoc:.</p>
310
+ </div></span>
311
+
312
+ </li>
313
+
314
+
315
+ <li class="public ">
316
+ <span class="summary_signature">
317
+
318
+ <a href="#execute-instance_method" title="#execute (instance method)">- (Object) <strong>execute</strong>(address, args) </a>
319
+
320
+
321
+
322
+ </span>
323
+
324
+
325
+
326
+
327
+
328
+
329
+
330
+
331
+
332
+ <span class="summary_desc"><div class='inline'>
333
+ <p>:nodoc:.</p>
334
+ </div></span>
335
+
336
+ </li>
337
+
338
+
339
+ <li class="public ">
340
+ <span class="summary_signature">
341
+
342
+ <a href="#get_channel-instance_method" title="#get_channel (instance method)">- (Object) <strong>get_channel</strong>(name, &amp;callback) </a>
343
+
344
+
345
+
346
+ </span>
347
+
348
+
349
+
350
+
351
+
352
+
353
+
354
+
355
+
356
+ <span class="summary_desc"><div class='inline'>
357
+ <p>:call-seq:.</p>
358
+ </div></span>
359
+
360
+ </li>
361
+
362
+
363
+ <li class="public ">
364
+ <span class="summary_signature">
365
+
366
+ <a href="#get_client-instance_method" title="#get_client (instance method)">- (Object) <strong>get_client</strong>(id) </a>
367
+
368
+
369
+
370
+ </span>
371
+
372
+
373
+
374
+
375
+
376
+
377
+
378
+
379
+
380
+ <span class="summary_desc"><div class='inline'></div></span>
381
+
382
+ </li>
383
+
384
+
385
+ <li class="public ">
386
+ <span class="summary_signature">
387
+
388
+ <a href="#get_service-instance_method" title="#get_service (instance method)">- (Object) <strong>get_service</strong>(name, &amp;callback) </a>
389
+
390
+
391
+
392
+ </span>
393
+
394
+
395
+
396
+
397
+
398
+
399
+
400
+
401
+
402
+ <span class="summary_desc"><div class='inline'>
403
+ <p>:call-seq:.</p>
404
+ </div></span>
405
+
406
+ </li>
407
+
408
+
409
+ <li class="public ">
410
+ <span class="summary_signature">
411
+
412
+ <a href="#initialize-instance_method" title="#initialize (instance method)">- (Bridge) <strong>initialize</strong>(options = {}) </a>
413
+
414
+
415
+
416
+ </span>
417
+
418
+
419
+ <span class="note title constructor">constructor</span>
420
+
421
+
422
+
423
+
424
+
425
+
426
+
427
+
428
+ <span class="summary_desc"><div class='inline'><dl class="rdoc-list note-list"><dt><code>:port =&gt; nil</code>
429
+ <dd>
430
+ <p>An integer specifying the port of the Bridge.</p>
431
+ </dd></dl>
432
+ </div></span>
433
+
434
+ </li>
435
+
436
+
437
+ <li class="public ">
438
+ <span class="summary_signature">
439
+
440
+ <a href="#join_channel-instance_method" title="#join_channel (instance method)">- (Object) <strong>join_channel</strong>(name, handler, writeable = true, &amp;callback) </a>
441
+
442
+
443
+
444
+ </span>
445
+
446
+
447
+
448
+
449
+
450
+
451
+
452
+
453
+
454
+ <span class="summary_desc"><div class='inline'><dl class="rdoc-list note-list"><dt><code>handler</code>
455
+ <dd>
456
+ <p>A remote object, ruby object or module to handle method.</p>
457
+ </dd></dl>
458
+ </div></span>
459
+
460
+ </li>
461
+
462
+
463
+ <li class="public ">
464
+ <span class="summary_signature">
465
+
466
+ <a href="#leave_channel-instance_method" title="#leave_channel (instance method)">- (Object) <strong>leave_channel</strong>(channel, handler, &amp;callback) </a>
467
+
468
+
469
+
470
+ </span>
471
+
472
+
473
+
474
+
475
+
476
+
477
+
478
+
479
+
480
+ <span class="summary_desc"><div class='inline'>
481
+ <p>:call-seq:.</p>
482
+ </div></span>
483
+
484
+ </li>
485
+
486
+
487
+ <li class="public ">
488
+ <span class="summary_signature">
489
+
490
+ <a href="#on-instance_method" title="#on (instance method)">- (Object) <strong>on</strong>(name, &amp;fn) </a>
491
+
492
+
493
+
494
+ </span>
495
+
496
+
497
+
498
+
499
+
500
+
501
+
502
+
503
+
504
+ <span class="summary_desc"><div class='inline'>
505
+ <p>:call-seq:.</p>
506
+ </div></span>
507
+
508
+ </li>
509
+
510
+
511
+ <li class="public ">
512
+ <span class="summary_signature">
513
+
514
+ <a href="#publish_service-instance_method" title="#publish_service (instance method)">- (Object) <strong>publish_service</strong>(name, handler, &amp;callback) </a>
515
+
516
+
517
+
518
+ </span>
519
+
520
+
521
+
522
+
523
+
524
+
525
+
526
+
527
+
528
+ <span class="summary_desc"><div class='inline'>
529
+ <p>:call-seq:.</p>
530
+ </div></span>
531
+
532
+ </li>
533
+
534
+
535
+ <li class="public ">
536
+ <span class="summary_signature">
537
+
538
+ <a href="#ready-instance_method" title="#ready (instance method)">- (Object) <strong>ready</strong>(&amp;callback) </a>
539
+
540
+
541
+
542
+ </span>
543
+
544
+
545
+
546
+
547
+
548
+
549
+
550
+
551
+
552
+ <span class="summary_desc"><div class='inline'>
553
+ <p>:call-seq:.</p>
554
+ </div></span>
555
+
556
+ </li>
557
+
558
+
559
+ <li class="public ">
560
+ <span class="summary_signature">
561
+
562
+ <a href="#send-instance_method" title="#send (instance method)">- (Object) <strong>send</strong>(args, destination) </a>
563
+
564
+
565
+
566
+ </span>
567
+
568
+
569
+
570
+
571
+
572
+
573
+
574
+
575
+
576
+ <span class="summary_desc"><div class='inline'>
577
+ <p>:nodoc:.</p>
578
+ </div></span>
579
+
580
+ </li>
581
+
582
+
583
+ <li class="public ">
584
+ <span class="summary_signature">
585
+
586
+ <a href="#store_object-instance_method" title="#store_object (instance method)">- (Object) <strong>store_object</strong>(handler, ops) </a>
587
+
588
+
589
+
590
+ </span>
591
+
592
+
593
+
594
+
595
+
596
+
597
+
598
+
599
+
600
+ <span class="summary_desc"><div class='inline'>
601
+ <p>:nodoc:.</p>
602
+ </div></span>
603
+
604
+ </li>
605
+
606
+
607
+ <li class="public ">
608
+ <span class="summary_signature">
609
+
610
+ <a href="#unpublish_service-instance_method" title="#unpublish_service (instance method)">- (Object) <strong>unpublish_service</strong>(name, &amp;callback) </a>
611
+
612
+
613
+
614
+ </span>
615
+
616
+
617
+
618
+
619
+
620
+
621
+
622
+
623
+
624
+ <span class="summary_desc"><div class='inline'>
625
+ <p>:call-seq:.</p>
626
+ </div></span>
627
+
628
+ </li>
629
+
630
+
631
+ </ul>
632
+
633
+
634
+ <div id="constructor_details" class="method_details_list">
635
+ <h2>Constructor Details</h2>
636
+
637
+ <div class="method_details first">
638
+ <h3 class="signature first" id="initialize-instance_method">
639
+
640
+ - (<tt><span class='object_link'><a href="" title="Bridge::Bridge (class)">Bridge</a></span></tt>) <strong>initialize</strong>(options = {})
641
+
642
+
643
+
644
+
645
+
646
+ </h3><div class="docstring">
647
+ <div class="discussion">
648
+ <dl class="rdoc-list note-list"><dt><code>:port =&gt; nil</code>
649
+ <dd>
650
+ <p>An integer specifying the port of the Bridge</p>
651
+ </dd></dl>
652
+
653
+ <pre class="code ruby"><code>server to connect to. Overrides +:redirector+ when both +:host+ and
654
+ +:port+ are specified.</code></pre>
655
+
656
+
657
+ </div>
658
+ </div>
659
+ <div class="tags">
660
+
661
+
662
+ </div><table class="source_code">
663
+ <tr>
664
+ <td>
665
+ <pre class="lines">
666
+
667
+
668
+ 69
669
+ 70
670
+ 71
671
+ 72
672
+ 73
673
+ 74
674
+ 75
675
+ 76
676
+ 77
677
+ 78
678
+ 79
679
+ 80
680
+ 81
681
+ 82
682
+ 83
683
+ 84
684
+ 85
685
+ 86
686
+ 87
687
+ 88
688
+ 89
689
+ 90
690
+ 91
691
+ 92
692
+ 93
693
+ 94
694
+ 95
695
+ 96
696
+ 97
697
+ 98
698
+ 99
699
+ 100
700
+ 101
701
+ 102</pre>
702
+ </td>
703
+ <td>
704
+ <pre class="code"><span class="info file"># File 'lib/bridge.rb', line 69</span>
705
+
706
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
707
+
708
+ <span class='comment'># Set default options
709
+ </span> <span class='ivar'>@options</span> <span class='op'>=</span> <span class='lbrace'>{</span>
710
+ <span class='symbol'>:redirector</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>http://redirector.getbridge.com</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
711
+ <span class='symbol'>:secure_redirector</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>https://redirector.getbridge.com</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
712
+ <span class='symbol'>:secure</span> <span class='op'>=&gt;</span> <span class='kw'>false</span><span class='comma'>,</span>
713
+ <span class='symbol'>:reconnect</span> <span class='op'>=&gt;</span> <span class='kw'>true</span><span class='comma'>,</span>
714
+ <span class='symbol'>:log</span> <span class='op'>=&gt;</span> <span class='int'>2</span><span class='comma'>,</span> <span class='comment'># 0 for no output
715
+ </span> <span class='rbrace'>}</span>
716
+
717
+ <span class='ivar'>@options</span> <span class='op'>=</span> <span class='ivar'>@options</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
718
+
719
+ <span class='kw'>if</span> <span class='ivar'>@options</span><span class='lbracket'>[</span><span class='symbol'>:secure</span><span class='rbracket'>]</span>
720
+ <span class='ivar'>@options</span><span class='lbracket'>[</span><span class='symbol'>:redirector</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='ivar'>@options</span><span class='lbracket'>[</span><span class='symbol'>:secure_redirector</span><span class='rbracket'>]</span>
721
+ <span class='kw'>end</span>
722
+
723
+ <span class='const'>Util</span><span class='period'>.</span><span class='id identifier rubyid_set_log_level'>set_log_level</span><span class='lparen'>(</span><span class='ivar'>@options</span><span class='lbracket'>[</span><span class='symbol'>:log</span><span class='rbracket'>]</span><span class='rparen'>)</span>
724
+
725
+ <span class='ivar'>@store</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
726
+ <span class='comment'># Initialize system service call
727
+ </span> <span class='ivar'>@store</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>system</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='const'>SystemService</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='rparen'>)</span>
728
+
729
+ <span class='comment'># Indicates whether server is connected and handshaken
730
+ </span> <span class='ivar'>@is_ready</span> <span class='op'>=</span> <span class='kw'>false</span>
731
+
732
+ <span class='comment'># Create connection object
733
+ </span> <span class='ivar'>@connection</span> <span class='op'>=</span> <span class='const'>Connection</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='rparen'>)</span>
734
+
735
+ <span class='comment'># Store event handlers
736
+ </span> <span class='ivar'>@events</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
737
+
738
+ <span class='ivar'>@context</span> <span class='op'>=</span> <span class='kw'>nil</span>
739
+ <span class='kw'>end</span></pre>
740
+ </td>
741
+ </tr>
742
+ </table>
743
+ </div>
744
+
745
+ </div>
746
+
747
+ <div id="instance_attr_details" class="attr_details">
748
+ <h2>Instance Attribute Details</h2>
749
+
750
+
751
+ <span id="connection=-instance_method"></span>
752
+ <div class="method_details first">
753
+ <h3 class="signature first" id="connection-instance_method">
754
+
755
+ - (<tt>Object</tt>) <strong>connection</strong>
756
+
757
+
758
+
759
+
760
+
761
+ </h3><div class="docstring">
762
+ <div class="discussion">
763
+
764
+ <p>:nodoc:</p>
765
+
766
+
767
+ </div>
768
+ </div>
769
+ <div class="tags">
770
+
771
+
772
+ </div><table class="source_code">
773
+ <tr>
774
+ <td>
775
+ <pre class="lines">
776
+
777
+
778
+ 34
779
+ 35
780
+ 36</pre>
781
+ </td>
782
+ <td>
783
+ <pre class="code"><span class="info file"># File 'lib/bridge.rb', line 34</span>
784
+
785
+ <span class='kw'>def</span> <span class='id identifier rubyid_connection'>connection</span>
786
+ <span class='ivar'>@connection</span>
787
+ <span class='kw'>end</span></pre>
788
+ </td>
789
+ </tr>
790
+ </table>
791
+ </div>
792
+
793
+
794
+ <span id="context=-instance_method"></span>
795
+ <div class="method_details ">
796
+ <h3 class="signature " id="context-instance_method">
797
+
798
+ - (<tt>Object</tt>) <strong>context</strong>
799
+
800
+
801
+
802
+
803
+
804
+ </h3><div class="docstring">
805
+ <div class="discussion">
806
+
807
+ <p>:nodoc:</p>
808
+
809
+
810
+ </div>
811
+ </div>
812
+ <div class="tags">
813
+
814
+
815
+ </div><table class="source_code">
816
+ <tr>
817
+ <td>
818
+ <pre class="lines">
819
+
820
+
821
+ 34
822
+ 35
823
+ 36</pre>
824
+ </td>
825
+ <td>
826
+ <pre class="code"><span class="info file"># File 'lib/bridge.rb', line 34</span>
827
+
828
+ <span class='kw'>def</span> <span class='id identifier rubyid_context'>context</span>
829
+ <span class='ivar'>@context</span>
830
+ <span class='kw'>end</span></pre>
831
+ </td>
832
+ </tr>
833
+ </table>
834
+ </div>
835
+
836
+
837
+ <span id="is_ready=-instance_method"></span>
838
+ <div class="method_details ">
839
+ <h3 class="signature " id="is_ready-instance_method">
840
+
841
+ - (<tt>Object</tt>) <strong>is_ready</strong>
842
+
843
+
844
+
845
+
846
+
847
+ </h3><div class="docstring">
848
+ <div class="discussion">
849
+
850
+ <p>:nodoc:</p>
851
+
852
+
853
+ </div>
854
+ </div>
855
+ <div class="tags">
856
+
857
+
858
+ </div><table class="source_code">
859
+ <tr>
860
+ <td>
861
+ <pre class="lines">
862
+
863
+
864
+ 34
865
+ 35
866
+ 36</pre>
867
+ </td>
868
+ <td>
869
+ <pre class="code"><span class="info file"># File 'lib/bridge.rb', line 34</span>
870
+
871
+ <span class='kw'>def</span> <span class='id identifier rubyid_is_ready'>is_ready</span>
872
+ <span class='ivar'>@is_ready</span>
873
+ <span class='kw'>end</span></pre>
874
+ </td>
875
+ </tr>
876
+ </table>
877
+ </div>
878
+
879
+
880
+ <span id="options=-instance_method"></span>
881
+ <div class="method_details ">
882
+ <h3 class="signature " id="options-instance_method">
883
+
884
+ - (<tt>Object</tt>) <strong>options</strong>
885
+
886
+
887
+
888
+
889
+
890
+ </h3><div class="docstring">
891
+ <div class="discussion">
892
+
893
+ <p>:nodoc:</p>
894
+
895
+
896
+ </div>
897
+ </div>
898
+ <div class="tags">
899
+
900
+
901
+ </div><table class="source_code">
902
+ <tr>
903
+ <td>
904
+ <pre class="lines">
905
+
906
+
907
+ 34
908
+ 35
909
+ 36</pre>
910
+ </td>
911
+ <td>
912
+ <pre class="code"><span class="info file"># File 'lib/bridge.rb', line 34</span>
913
+
914
+ <span class='kw'>def</span> <span class='id identifier rubyid_options'>options</span>
915
+ <span class='ivar'>@options</span>
916
+ <span class='kw'>end</span></pre>
917
+ </td>
918
+ </tr>
919
+ </table>
920
+ </div>
921
+
922
+
923
+ <span id="store=-instance_method"></span>
924
+ <div class="method_details ">
925
+ <h3 class="signature " id="store-instance_method">
926
+
927
+ - (<tt>Object</tt>) <strong>store</strong>
928
+
929
+
930
+
931
+
932
+
933
+ </h3><div class="docstring">
934
+ <div class="discussion">
935
+
936
+ <p>:nodoc:</p>
937
+
938
+
939
+ </div>
940
+ </div>
941
+ <div class="tags">
942
+
943
+
944
+ </div><table class="source_code">
945
+ <tr>
946
+ <td>
947
+ <pre class="lines">
948
+
949
+
950
+ 34
951
+ 35
952
+ 36</pre>
953
+ </td>
954
+ <td>
955
+ <pre class="code"><span class="info file"># File 'lib/bridge.rb', line 34</span>
956
+
957
+ <span class='kw'>def</span> <span class='id identifier rubyid_store'>store</span>
958
+ <span class='ivar'>@store</span>
959
+ <span class='kw'>end</span></pre>
960
+ </td>
961
+ </tr>
962
+ </table>
963
+ </div>
964
+
965
+ </div>
966
+
967
+
968
+ <div id="instance_method_details" class="method_details_list">
969
+ <h2>Instance Method Details</h2>
970
+
971
+
972
+ <div class="method_details first">
973
+ <h3 class="signature first" id="connect-instance_method">
974
+
975
+ - (<tt>Object</tt>) <strong>connect</strong>(&amp;callback)
976
+
977
+
978
+
979
+
980
+
981
+ </h3><div class="docstring">
982
+ <div class="discussion">
983
+
984
+ <p>:call-seq:</p>
985
+
986
+ <pre class="code ruby"><code><span class='id identifier rubyid_connect'>connect</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_block'>block</span> <span class='rbrace'>}</span></code></pre>
987
+
988
+ <p>Starts the connection to the Bridge server.</p>
989
+
990
+ <p>If a block is given, calls the given block when Bridge is connected</p>
991
+
992
+ <pre class="code ruby"><code>and ready.</code></pre>
993
+
994
+
995
+ </div>
996
+ </div>
997
+ <div class="tags">
998
+
999
+
1000
+ </div><table class="source_code">
1001
+ <tr>
1002
+ <td>
1003
+ <pre class="lines">
1004
+
1005
+
1006
+ 380
1007
+ 381
1008
+ 382
1009
+ 383
1010
+ 384</pre>
1011
+ </td>
1012
+ <td>
1013
+ <pre class="code"><span class="info file"># File 'lib/bridge.rb', line 380</span>
1014
+
1015
+ <span class='kw'>def</span> <span class='id identifier rubyid_connect'>connect</span> <span class='op'>&amp;</span><span class='id identifier rubyid_callback'>callback</span>
1016
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_ready'>ready</span> <span class='op'>&amp;</span><span class='id identifier rubyid_callback'>callback</span> <span class='kw'>if</span> <span class='id identifier rubyid_callback'>callback</span>
1017
+ <span class='ivar'>@connection</span><span class='period'>.</span><span class='id identifier rubyid_start'>start</span>
1018
+ <span class='kw'>return</span> <span class='kw'>self</span>
1019
+ <span class='kw'>end</span></pre>
1020
+ </td>
1021
+ </tr>
1022
+ </table>
1023
+ </div>
1024
+
1025
+ <div class="method_details ">
1026
+ <h3 class="signature " id="emit-instance_method">
1027
+
1028
+ - (<tt>Object</tt>) <strong>emit</strong>(name, args = [])
1029
+
1030
+
1031
+
1032
+
1033
+
1034
+ </h3><div class="docstring">
1035
+ <div class="discussion">
1036
+
1037
+ <p>:nodoc:</p>
1038
+
1039
+
1040
+ </div>
1041
+ </div>
1042
+ <div class="tags">
1043
+
1044
+
1045
+ </div><table class="source_code">
1046
+ <tr>
1047
+ <td>
1048
+ <pre class="lines">
1049
+
1050
+
1051
+ 166
1052
+ 167
1053
+ 168
1054
+ 169
1055
+ 170
1056
+ 171
1057
+ 172</pre>
1058
+ </td>
1059
+ <td>
1060
+ <pre class="code"><span class="info file"># File 'lib/bridge.rb', line 166</span>
1061
+
1062
+ <span class='kw'>def</span> <span class='id identifier rubyid_emit'>emit</span> <span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_args'>args</span><span class='op'>=</span><span class='lbracket'>[</span><span class='rbracket'>]</span> <span class='comment'>#:nodoc:
1063
+ </span> <span class='kw'>if</span> <span class='ivar'>@events</span><span class='period'>.</span><span class='id identifier rubyid_key?'>key?</span> <span class='id identifier rubyid_name'>name</span>
1064
+ <span class='ivar'>@events</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_fn'>fn</span><span class='op'>|</span>
1065
+ <span class='id identifier rubyid_fn'>fn</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span>
1066
+ <span class='kw'>end</span>
1067
+ <span class='kw'>end</span>
1068
+ <span class='kw'>end</span></pre>
1069
+ </td>
1070
+ </tr>
1071
+ </table>
1072
+ </div>
1073
+
1074
+ <div class="method_details ">
1075
+ <h3 class="signature " id="execute-instance_method">
1076
+
1077
+ - (<tt>Object</tt>) <strong>execute</strong>(address, args)
1078
+
1079
+
1080
+
1081
+
1082
+
1083
+ </h3><div class="docstring">
1084
+ <div class="discussion">
1085
+
1086
+ <p>:nodoc:</p>
1087
+
1088
+
1089
+ </div>
1090
+ </div>
1091
+ <div class="tags">
1092
+
1093
+
1094
+ </div><table class="source_code">
1095
+ <tr>
1096
+ <td>
1097
+ <pre class="lines">
1098
+
1099
+
1100
+ 104
1101
+ 105
1102
+ 106
1103
+ 107
1104
+ 108
1105
+ 109
1106
+ 110
1107
+ 111
1108
+ 112
1109
+ 113
1110
+ 114
1111
+ 115
1112
+ 116
1113
+ 117
1114
+ 118
1115
+ 119
1116
+ 120
1117
+ 121
1118
+ 122
1119
+ 123
1120
+ 124
1121
+ 125
1122
+ 126
1123
+ 127
1124
+ 128
1125
+ 129
1126
+ 130</pre>
1127
+ </td>
1128
+ <td>
1129
+ <pre class="code"><span class="info file"># File 'lib/bridge.rb', line 104</span>
1130
+
1131
+ <span class='kw'>def</span> <span class='id identifier rubyid_execute'>execute</span> <span class='id identifier rubyid_address'>address</span><span class='comma'>,</span> <span class='id identifier rubyid_args'>args</span> <span class='comment'>#:nodoc:
1132
+ </span> <span class='comment'># Retrieve stored handler
1133
+ </span> <span class='id identifier rubyid_obj'>obj</span> <span class='op'>=</span> <span class='ivar'>@store</span><span class='lbracket'>[</span><span class='id identifier rubyid_address'>address</span><span class='lbracket'>[</span><span class='int'>2</span><span class='rbracket'>]</span><span class='rbracket'>]</span>
1134
+ <span class='comment'># Retrieve function in handler
1135
+ </span> <span class='id identifier rubyid_func'>func</span> <span class='op'>=</span> <span class='id identifier rubyid_obj'>obj</span><span class='period'>.</span><span class='id identifier rubyid_method'>method</span><span class='lparen'>(</span><span class='id identifier rubyid_address'>address</span><span class='lbracket'>[</span><span class='int'>3</span><span class='rbracket'>]</span><span class='rparen'>)</span>
1136
+ <span class='kw'>if</span> <span class='id identifier rubyid_func'>func</span>
1137
+ <span class='id identifier rubyid_last'>last</span> <span class='op'>=</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_last'>last</span>
1138
+ <span class='comment'># If last argument is callable and function arity is one less than
1139
+ </span> <span class='comment'># args length, pass in as block
1140
+ </span> <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_last'>last</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span> <span class='const'>Proc</span><span class='rparen'>)</span> <span class='kw'>and</span> <span class='id identifier rubyid_func'>func</span><span class='period'>.</span><span class='id identifier rubyid_arity'>arity</span> <span class='op'>==</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>-</span> <span class='int'>1</span>
1141
+ <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_pop'>pop</span>
1142
+ <span class='id identifier rubyid_func'>func</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span> <span class='kw'>do</span> <span class='op'>|</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_blk'>blk</span><span class='op'>|</span>
1143
+ <span class='id identifier rubyid_args'>args</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_blk'>blk</span> <span class='kw'>if</span> <span class='id identifier rubyid_blk'>blk</span>
1144
+ <span class='id identifier rubyid_last'>last</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span>
1145
+ <span class='kw'>end</span>
1146
+ <span class='kw'>else</span>
1147
+ <span class='kw'>begin</span>
1148
+ <span class='id identifier rubyid_func'>func</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span>
1149
+ <span class='kw'>rescue</span> <span class='const'>StandardError</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_err'>err</span>
1150
+ <span class='const'>Util</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span> <span class='id identifier rubyid_err'>err</span>
1151
+ <span class='const'>Util</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Exception while calling </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_address'>address</span><span class='lbracket'>[</span><span class='int'>3</span><span class='rbracket'>]</span><span class='rbrace'>}</span><span class='tstring_content'>(</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_args'>args</span><span class='rbrace'>}</span><span class='tstring_content'>)</span><span class='tstring_end'>&quot;</span></span>
1152
+ <span class='kw'>end</span>
1153
+ <span class='kw'>end</span>
1154
+ <span class='kw'>else</span>
1155
+ <span class='const'>Util</span><span class='period'>.</span><span class='id identifier rubyid_warn'>warn</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Could not find object to handle, </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_address'>address</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span>
1156
+ <span class='kw'>end</span>
1157
+ <span class='kw'>end</span></pre>
1158
+ </td>
1159
+ </tr>
1160
+ </table>
1161
+ </div>
1162
+
1163
+ <div class="method_details ">
1164
+ <h3 class="signature " id="get_channel-instance_method">
1165
+
1166
+ - (<tt>Object</tt>) <strong>get_channel</strong>(name, &amp;callback)
1167
+
1168
+
1169
+
1170
+
1171
+
1172
+ </h3><div class="docstring">
1173
+ <div class="discussion">
1174
+
1175
+ <p>:call-seq:</p>
1176
+
1177
+ <pre class="ruby"><span class="ruby-identifier">get_channel</span>(<span class="ruby-identifier">name</span>) <span class="ruby-operator">-</span><span class="ruby-operator">&gt;</span> <span class="ruby-identifier">channel</span>
1178
+ <span class="ruby-identifier">get_channel</span>(<span class="ruby-identifier">name</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">channel</span>, <span class="ruby-identifier">name</span><span class="ruby-operator">|</span> <span class="ruby-identifier">block</span> }
1179
+ </pre>
1180
+
1181
+ <p>Retrives a channel from Bridge with the given name.</p>
1182
+
1183
+ <p>Calling a method on the channel object will result in the given</p>
1184
+
1185
+ <pre class="code ruby"><code>method being executed on all clients that have been joined to the
1186
+ channel.</code></pre>
1187
+
1188
+ <p>Note that if the requested channel does not exist or is empty, an</p>
1189
+
1190
+ <pre class="code ruby"><code>object is still returned, however attempts to make method calls on
1191
+ the object will result in a remote error.</code></pre>
1192
+
1193
+ <p>Returns the requested channel.</p>
1194
+
1195
+ <p>If a block is given, calls the given block with the requested channel</p>
1196
+
1197
+ <pre class="code ruby"><code>and channel name.</code></pre>
1198
+
1199
+ <h3 id="label-Attributes++">Attributes </h3>
1200
+ <dl class="rdoc-list note-list"><dt><code>name</code>
1201
+ <dd>
1202
+ <p>The name of the Bridge channel being requested</p>
1203
+ </dd></dl>
1204
+
1205
+
1206
+ </div>
1207
+ </div>
1208
+ <div class="tags">
1209
+
1210
+
1211
+ </div><table class="source_code">
1212
+ <tr>
1213
+ <td>
1214
+ <pre class="lines">
1215
+
1216
+
1217
+ 289
1218
+ 290
1219
+ 291
1220
+ 292
1221
+ 293
1222
+ 294
1223
+ 295
1224
+ 296</pre>
1225
+ </td>
1226
+ <td>
1227
+ <pre class="code"><span class="info file"># File 'lib/bridge.rb', line 289</span>
1228
+
1229
+ <span class='kw'>def</span> <span class='id identifier rubyid_get_channel'>get_channel</span> <span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_callback'>callback</span>
1230
+ <span class='comment'># Send GETCHANNEL command in order to establih link for channel if
1231
+ </span> <span class='comment'># client is not member
1232
+ </span> <span class='ivar'>@connection</span><span class='period'>.</span><span class='id identifier rubyid_send_command'>send_command</span><span class='lparen'>(</span><span class='symbol'>:GETCHANNEL</span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='symbol'>:name</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_name'>name</span><span class='rbrace'>}</span><span class='rparen'>)</span>
1233
+ <span class='id identifier rubyid_ref'>ref</span> <span class='op'>=</span> <span class='const'>Reference</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>channel</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>channel:</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
1234
+ <span class='id identifier rubyid_callback'>callback</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_ref'>ref</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_callback'>callback</span>
1235
+ <span class='kw'>return</span> <span class='id identifier rubyid_ref'>ref</span>
1236
+ <span class='kw'>end</span></pre>
1237
+ </td>
1238
+ </tr>
1239
+ </table>
1240
+ </div>
1241
+
1242
+ <div class="method_details ">
1243
+ <h3 class="signature " id="get_client-instance_method">
1244
+
1245
+ - (<tt>Object</tt>) <strong>get_client</strong>(id)
1246
+
1247
+
1248
+
1249
+
1250
+
1251
+ </h3><table class="source_code">
1252
+ <tr>
1253
+ <td>
1254
+ <pre class="lines">
1255
+
1256
+
1257
+ 262
1258
+ 263
1259
+ 264</pre>
1260
+ </td>
1261
+ <td>
1262
+ <pre class="code"><span class="info file"># File 'lib/bridge.rb', line 262</span>
1263
+
1264
+ <span class='kw'>def</span> <span class='id identifier rubyid_get_client'>get_client</span> <span class='id identifier rubyid_id'>id</span>
1265
+ <span class='kw'>return</span> <span class='const'>Client</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_id'>id</span><span class='rparen'>)</span>
1266
+ <span class='kw'>end</span></pre>
1267
+ </td>
1268
+ </tr>
1269
+ </table>
1270
+ </div>
1271
+
1272
+ <div class="method_details ">
1273
+ <h3 class="signature " id="get_service-instance_method">
1274
+
1275
+ - (<tt>Object</tt>) <strong>get_service</strong>(name, &amp;callback)
1276
+
1277
+
1278
+
1279
+
1280
+
1281
+ </h3><div class="docstring">
1282
+ <div class="discussion">
1283
+
1284
+ <p>:call-seq:</p>
1285
+
1286
+ <pre class="ruby"><span class="ruby-identifier">get_service</span>(<span class="ruby-identifier">name</span>) <span class="ruby-operator">-</span><span class="ruby-operator">&gt;</span> <span class="ruby-identifier">service</span>
1287
+ <span class="ruby-identifier">get_service</span>(<span class="ruby-identifier">name</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">service</span>, <span class="ruby-identifier">name</span><span class="ruby-operator">|</span> <span class="ruby-identifier">block</span> }
1288
+ </pre>
1289
+
1290
+ <p>Retrives a service published to Bridge with the given name.</p>
1291
+
1292
+ <p>If multiple Bridge clients have a published a service, the service is</p>
1293
+
1294
+ <pre class="code ruby"><code>retrieved from one of the publishers round-robin.</code></pre>
1295
+
1296
+ <p>Note that if the requested service does not exist, an object is still</p>
1297
+
1298
+ <pre class="code ruby"><code>returned, however attempts to make method calls on the object will
1299
+ result in a remote error.</code></pre>
1300
+
1301
+ <p>Returns the requested service.</p>
1302
+
1303
+ <p>If a block is given, calls the given block with the requested service</p>
1304
+
1305
+ <pre class="code ruby"><code>and service name.</code></pre>
1306
+
1307
+ <h3 id="label-Attributes++">Attributes </h3>
1308
+ <dl class="rdoc-list note-list"><dt><code>name</code>
1309
+ <dd>
1310
+ <p>The name of the Bridge service being requested</p>
1311
+ </dd></dl>
1312
+
1313
+
1314
+ </div>
1315
+ </div>
1316
+ <div class="tags">
1317
+
1318
+
1319
+ </div><table class="source_code">
1320
+ <tr>
1321
+ <td>
1322
+ <pre class="lines">
1323
+
1324
+
1325
+ 256
1326
+ 257
1327
+ 258
1328
+ 259
1329
+ 260</pre>
1330
+ </td>
1331
+ <td>
1332
+ <pre class="code"><span class="info file"># File 'lib/bridge.rb', line 256</span>
1333
+
1334
+ <span class='kw'>def</span> <span class='id identifier rubyid_get_service'>get_service</span> <span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_callback'>callback</span>
1335
+ <span class='id identifier rubyid_ref'>ref</span> <span class='op'>=</span> <span class='const'>Reference</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>named</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span><span class='rparen'>)</span>
1336
+ <span class='id identifier rubyid_callback'>callback</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_ref'>ref</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_callback'>callback</span>
1337
+ <span class='kw'>return</span> <span class='id identifier rubyid_ref'>ref</span>
1338
+ <span class='kw'>end</span></pre>
1339
+ </td>
1340
+ </tr>
1341
+ </table>
1342
+ </div>
1343
+
1344
+ <div class="method_details ">
1345
+ <h3 class="signature " id="join_channel-instance_method">
1346
+
1347
+ - (<tt>Object</tt>) <strong>join_channel</strong>(name, handler, writeable = true, &amp;callback)
1348
+
1349
+
1350
+
1351
+
1352
+
1353
+ </h3><div class="docstring">
1354
+ <div class="discussion">
1355
+ <dl class="rdoc-list note-list"><dt><code>handler</code>
1356
+ <dd>
1357
+ <p>A remote object, ruby object or module to handle method</p>
1358
+ </dd></dl>
1359
+
1360
+ <pre class="code ruby"><code><span class='id identifier rubyid_calls'>calls</span> <span class='id identifier rubyid_from'>from</span> <span class='id identifier rubyid_the'>the</span> <span class='id identifier rubyid_channel'>channel</span></code></pre>
1361
+
1362
+
1363
+ </div>
1364
+ </div>
1365
+ <div class="tags">
1366
+
1367
+
1368
+ </div><table class="source_code">
1369
+ <tr>
1370
+ <td>
1371
+ <pre class="lines">
1372
+
1373
+
1374
+ 319
1375
+ 320
1376
+ 321
1377
+ 322
1378
+ 323
1379
+ 324
1380
+ 325
1381
+ 326
1382
+ 327
1383
+ 328</pre>
1384
+ </td>
1385
+ <td>
1386
+ <pre class="code"><span class="info file"># File 'lib/bridge.rb', line 319</span>
1387
+
1388
+ <span class='kw'>def</span> <span class='id identifier rubyid_join_channel'>join_channel</span> <span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_handler'>handler</span><span class='comma'>,</span> <span class='id identifier rubyid_writeable'>writeable</span> <span class='op'>=</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_callback'>callback</span>
1389
+ <span class='ivar'>@connection</span><span class='period'>.</span><span class='id identifier rubyid_send_command'>send_command</span><span class='lparen'>(</span>
1390
+ <span class='symbol'>:JOINCHANNEL</span><span class='comma'>,</span>
1391
+ <span class='lbrace'>{</span> <span class='symbol'>:name</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_name'>name</span><span class='comma'>,</span>
1392
+ <span class='symbol'>:handler</span> <span class='op'>=&gt;</span> <span class='const'>Serializer</span><span class='period'>.</span><span class='id identifier rubyid_serialize'>serialize</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_handler'>handler</span><span class='rparen'>)</span><span class='comma'>,</span>
1393
+ <span class='symbol'>:callback</span> <span class='op'>=&gt;</span> <span class='const'>Serializer</span><span class='period'>.</span><span class='id identifier rubyid_serialize'>serialize</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_callback'>callback</span><span class='rparen'>)</span><span class='comma'>,</span>
1394
+ <span class='symbol'>:writeable</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_writeable'>writeable</span>
1395
+ <span class='rbrace'>}</span>
1396
+ <span class='rparen'>)</span>
1397
+ <span class='kw'>end</span></pre>
1398
+ </td>
1399
+ </tr>
1400
+ </table>
1401
+ </div>
1402
+
1403
+ <div class="method_details ">
1404
+ <h3 class="signature " id="leave_channel-instance_method">
1405
+
1406
+ - (<tt>Object</tt>) <strong>leave_channel</strong>(channel, handler, &amp;callback)
1407
+
1408
+
1409
+
1410
+
1411
+
1412
+ </h3><div class="docstring">
1413
+ <div class="discussion">
1414
+
1415
+ <p>:call-seq:</p>
1416
+
1417
+ <pre class="ruby"><span class="ruby-identifier">leave_channel</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">handler</span>)
1418
+ <span class="ruby-identifier">leave_channel</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">handler</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span> <span class="ruby-identifier">block</span> }
1419
+ </pre>
1420
+
1421
+ <p>Leaves a Bridge channel with the given name and handler object.</p>
1422
+
1423
+ <p>The given handler can be a remote object, in which case the Bridge</p>
1424
+
1425
+ <pre class="code ruby"><code>client that created the remote object will be removed from the
1426
+ channel.</code></pre>
1427
+
1428
+ <p>If a block is given, calls the given block with the name of the</p>
1429
+
1430
+ <pre class="code ruby"><code>channel left.</code></pre>
1431
+
1432
+ <h3 id="label-Attributes++">Attributes </h3>
1433
+ <dl class="rdoc-list note-list"><dt><code>name</code>
1434
+ <dd>
1435
+ <p>The name of the Bridge channel to leave</p>
1436
+ </dd><dt><code>handler</code>
1437
+ <dd>
1438
+ <p>A remote object, ruby object or module that was used to</p>
1439
+ </dd></dl>
1440
+
1441
+ <pre class="code ruby"><code><span class='id identifier rubyid_handle'>handle</span> <span class='id identifier rubyid_moethod'>moethod</span> <span class='id identifier rubyid_calls'>calls</span> <span class='id identifier rubyid_from'>from</span> <span class='id identifier rubyid_the'>the</span> <span class='id identifier rubyid_channel'>channel</span></code></pre>
1442
+
1443
+
1444
+ </div>
1445
+ </div>
1446
+ <div class="tags">
1447
+
1448
+
1449
+ </div><table class="source_code">
1450
+ <tr>
1451
+ <td>
1452
+ <pre class="lines">
1453
+
1454
+
1455
+ 349
1456
+ 350
1457
+ 351
1458
+ 352
1459
+ 353
1460
+ 354
1461
+ 355
1462
+ 356</pre>
1463
+ </td>
1464
+ <td>
1465
+ <pre class="code"><span class="info file"># File 'lib/bridge.rb', line 349</span>
1466
+
1467
+ <span class='kw'>def</span> <span class='id identifier rubyid_leave_channel'>leave_channel</span> <span class='id identifier rubyid_channel'>channel</span><span class='comma'>,</span> <span class='id identifier rubyid_handler'>handler</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_callback'>callback</span>
1468
+ <span class='ivar'>@connection</span><span class='period'>.</span><span class='id identifier rubyid_send_command'>send_command</span><span class='lparen'>(</span>
1469
+ <span class='symbol'>:LEAVECHANNEL</span><span class='comma'>,</span>
1470
+ <span class='lbrace'>{</span> <span class='symbol'>:name</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_name'>name</span><span class='comma'>,</span>
1471
+ <span class='symbol'>:handler</span> <span class='op'>=&gt;</span> <span class='const'>Serializer</span><span class='period'>.</span><span class='id identifier rubyid_serialize'>serialize</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_handler'>handler</span><span class='rparen'>)</span><span class='comma'>,</span>
1472
+ <span class='symbol'>:callback</span> <span class='op'>=&gt;</span> <span class='const'>Serializer</span><span class='period'>.</span><span class='id identifier rubyid_serialize'>serialize</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_callback'>callback</span><span class='rparen'>)</span><span class='rbrace'>}</span>
1473
+ <span class='rparen'>)</span>
1474
+ <span class='kw'>end</span></pre>
1475
+ </td>
1476
+ </tr>
1477
+ </table>
1478
+ </div>
1479
+
1480
+ <div class="method_details ">
1481
+ <h3 class="signature " id="on-instance_method">
1482
+
1483
+ - (<tt>Object</tt>) <strong>on</strong>(name, &amp;fn)
1484
+
1485
+
1486
+
1487
+
1488
+
1489
+ </h3><div class="docstring">
1490
+ <div class="discussion">
1491
+
1492
+ <p>:call-seq:</p>
1493
+
1494
+ <pre class="ruby"><span class="ruby-identifier">on</span>(<span class="ruby-identifier">name</span>) { <span class="ruby-operator">|</span>*<span class="ruby-identifier">args</span><span class="ruby-operator">|</span> <span class="ruby-identifier">block</span> }
1495
+ </pre>
1496
+
1497
+ <p>Adds the given block as a handler for the event specified by</p>
1498
+
1499
+ <pre class="code ruby"><code>&lt;tt&gt;name&lt;/tt&gt;. Calling multiple times will result in multiple
1500
+ handlers being attached to the event</code></pre>
1501
+
1502
+ <h3 id="label-Attributes++">Attributes </h3>
1503
+ <dl class="rdoc-list note-list"><dt><code>name</code>
1504
+ <dd>
1505
+ <p>The name of the event for the given block to listen to</p>
1506
+ </dd></dl>
1507
+
1508
+ <h3 id="label-Events++">Events </h3>
1509
+
1510
+ <p>List of events Bridge emits</p>
1511
+ <dl class="rdoc-list note-list"><dt><code>'ready' ()</code>
1512
+ <dd>
1513
+ <p>Bridge is connected and ready. Not emitted on</p>
1514
+ </dd></dl>
1515
+
1516
+ <pre class="code ruby"><code><span class='id identifier rubyid_reconnects'>reconnects</span></code></pre>
1517
+ <dl class="rdoc-list note-list"><dt><code>'remoteError' (error_message)</code>
1518
+ <dd>
1519
+ <p>A remote error has occurred</p>
1520
+ </dd></dl>
1521
+
1522
+ <pre class="code ruby"><code>in Bridge. The error message is provided as a parameter</code></pre>
1523
+
1524
+
1525
+ </div>
1526
+ </div>
1527
+ <div class="tags">
1528
+
1529
+
1530
+ </div><table class="source_code">
1531
+ <tr>
1532
+ <td>
1533
+ <pre class="lines">
1534
+
1535
+
1536
+ 159
1537
+ 160
1538
+ 161
1539
+ 162
1540
+ 163
1541
+ 164</pre>
1542
+ </td>
1543
+ <td>
1544
+ <pre class="code"><span class="info file"># File 'lib/bridge.rb', line 159</span>
1545
+
1546
+ <span class='kw'>def</span> <span class='id identifier rubyid_on'>on</span> <span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_fn'>fn</span>
1547
+ <span class='kw'>if</span> <span class='op'>!</span><span class='ivar'>@events</span><span class='period'>.</span><span class='id identifier rubyid_key?'>key?</span> <span class='id identifier rubyid_name'>name</span>
1548
+ <span class='ivar'>@events</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='semicolon'>;</span>
1549
+ <span class='kw'>end</span>
1550
+ <span class='ivar'>@events</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_fn'>fn</span>
1551
+ <span class='kw'>end</span></pre>
1552
+ </td>
1553
+ </tr>
1554
+ </table>
1555
+ </div>
1556
+
1557
+ <div class="method_details ">
1558
+ <h3 class="signature " id="publish_service-instance_method">
1559
+
1560
+ - (<tt>Object</tt>) <strong>publish_service</strong>(name, handler, &amp;callback)
1561
+
1562
+
1563
+
1564
+
1565
+
1566
+ </h3><div class="docstring">
1567
+ <div class="discussion">
1568
+
1569
+ <p>:call-seq:</p>
1570
+
1571
+ <pre class="ruby"><span class="ruby-identifier">publish_service</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">handler</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span> <span class="ruby-identifier">block</span> }
1572
+ </pre>
1573
+
1574
+ <p>Publishes a ruby object or module as a Bridge service with the given</p>
1575
+
1576
+ <pre class="code ruby"><code>name.</code></pre>
1577
+
1578
+ <p>If a block is given, calls the given block with the name of the</p>
1579
+
1580
+ <pre class="code ruby"><code><span class='id identifier rubyid_published'>published</span> <span class='id identifier rubyid_service'>service</span> <span class='id identifier rubyid_upon'>upon</span> <span class='id identifier rubyid_publish'>publish</span> <span class='id identifier rubyid_success'>success</span></code></pre>
1581
+
1582
+ <h3 id="label-Attributes++">Attributes </h3>
1583
+ <dl class="rdoc-list note-list"><dt><code>name</code>
1584
+ <dd>
1585
+ <p>The name of the Bridge service the handler will be published</p>
1586
+ </dd></dl>
1587
+
1588
+ <pre class="code ruby"><code><span class='id identifier rubyid_with'>with</span></code></pre>
1589
+ <dl class="rdoc-list note-list"><dt><code>handler</code>
1590
+ <dd>
1591
+ <p>A ruby object or module to publish</p>
1592
+ </dd></dl>
1593
+
1594
+
1595
+ </div>
1596
+ </div>
1597
+ <div class="tags">
1598
+
1599
+
1600
+ </div><table class="source_code">
1601
+ <tr>
1602
+ <td>
1603
+ <pre class="lines">
1604
+
1605
+
1606
+ 195
1607
+ 196
1608
+ 197
1609
+ 198
1610
+ 199
1611
+ 200
1612
+ 201
1613
+ 202
1614
+ 203
1615
+ 204
1616
+ 205
1617
+ 206</pre>
1618
+ </td>
1619
+ <td>
1620
+ <pre class="code"><span class="info file"># File 'lib/bridge.rb', line 195</span>
1621
+
1622
+ <span class='kw'>def</span> <span class='id identifier rubyid_publish_service'>publish_service</span> <span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_handler'>handler</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_callback'>callback</span>
1623
+ <span class='kw'>if</span> <span class='id identifier rubyid_name'>name</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>system</span><span class='tstring_end'>'</span></span>
1624
+ <span class='const'>Util</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Invalid service name: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
1625
+ <span class='kw'>else</span>
1626
+ <span class='ivar'>@store</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_handler'>handler</span>
1627
+ <span class='ivar'>@connection</span><span class='period'>.</span><span class='id identifier rubyid_send_command'>send_command</span><span class='lparen'>(</span>
1628
+ <span class='symbol'>:JOINWORKERPOOL</span><span class='comma'>,</span>
1629
+ <span class='lbrace'>{</span> <span class='symbol'>:name</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_name'>name</span><span class='comma'>,</span>
1630
+ <span class='symbol'>:callback</span> <span class='op'>=&gt;</span> <span class='const'>Serializer</span><span class='period'>.</span><span class='id identifier rubyid_serialize'>serialize</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_callback'>callback</span><span class='rparen'>)</span><span class='rbrace'>}</span>
1631
+ <span class='rparen'>)</span>
1632
+ <span class='kw'>end</span>
1633
+ <span class='kw'>end</span></pre>
1634
+ </td>
1635
+ </tr>
1636
+ </table>
1637
+ </div>
1638
+
1639
+ <div class="method_details ">
1640
+ <h3 class="signature " id="ready-instance_method">
1641
+
1642
+ - (<tt>Object</tt>) <strong>ready</strong>(&amp;callback)
1643
+
1644
+
1645
+
1646
+
1647
+
1648
+ </h3><div class="docstring">
1649
+ <div class="discussion">
1650
+
1651
+ <p>:call-seq:</p>
1652
+
1653
+ <pre class="code ruby"><code><span class='id identifier rubyid_ready'>ready</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_block'>block</span> <span class='rbrace'>}</span></code></pre>
1654
+
1655
+ <p>Calls the given block when Bridge is connected and ready. Calls the given
1656
+ block immediately if Bridge is already ready.</p>
1657
+
1658
+
1659
+ </div>
1660
+ </div>
1661
+ <div class="tags">
1662
+
1663
+
1664
+ </div><table class="source_code">
1665
+ <tr>
1666
+ <td>
1667
+ <pre class="lines">
1668
+
1669
+
1670
+ 364
1671
+ 365
1672
+ 366
1673
+ 367
1674
+ 368
1675
+ 369
1676
+ 370</pre>
1677
+ </td>
1678
+ <td>
1679
+ <pre class="code"><span class="info file"># File 'lib/bridge.rb', line 364</span>
1680
+
1681
+ <span class='kw'>def</span> <span class='id identifier rubyid_ready'>ready</span> <span class='op'>&amp;</span><span class='id identifier rubyid_callback'>callback</span>
1682
+ <span class='kw'>if</span> <span class='ivar'>@is_ready</span>
1683
+ <span class='id identifier rubyid_callback'>callback</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span>
1684
+ <span class='kw'>else</span>
1685
+ <span class='id identifier rubyid_on'>on</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>ready</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_callback'>callback</span>
1686
+ <span class='kw'>end</span>
1687
+ <span class='kw'>end</span></pre>
1688
+ </td>
1689
+ </tr>
1690
+ </table>
1691
+ </div>
1692
+
1693
+ <div class="method_details ">
1694
+ <h3 class="signature " id="send-instance_method">
1695
+
1696
+ - (<tt>Object</tt>) <strong>send</strong>(args, destination)
1697
+
1698
+
1699
+
1700
+
1701
+
1702
+ </h3><div class="docstring">
1703
+ <div class="discussion">
1704
+
1705
+ <p>:nodoc:</p>
1706
+
1707
+
1708
+ </div>
1709
+ </div>
1710
+ <div class="tags">
1711
+
1712
+
1713
+ </div><table class="source_code">
1714
+ <tr>
1715
+ <td>
1716
+ <pre class="lines">
1717
+
1718
+
1719
+ 174
1720
+ 175
1721
+ 176
1722
+ 177
1723
+ 178</pre>
1724
+ </td>
1725
+ <td>
1726
+ <pre class="code"><span class="info file"># File 'lib/bridge.rb', line 174</span>
1727
+
1728
+ <span class='kw'>def</span> <span class='id identifier rubyid_send'>send</span> <span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='id identifier rubyid_destination'>destination</span> <span class='comment'>#:nodoc:
1729
+ </span> <span class='ivar'>@connection</span><span class='period'>.</span><span class='id identifier rubyid_send_command'>send_command</span><span class='lparen'>(</span><span class='symbol'>:SEND</span><span class='comma'>,</span>
1730
+ <span class='lbrace'>{</span> <span class='symbol'>:args</span> <span class='op'>=&gt;</span> <span class='const'>Serializer</span><span class='period'>.</span><span class='id identifier rubyid_serialize'>serialize</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span><span class='comma'>,</span>
1731
+ <span class='symbol'>:destination</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_destination'>destination</span> <span class='rbrace'>}</span><span class='rparen'>)</span>
1732
+ <span class='kw'>end</span></pre>
1733
+ </td>
1734
+ </tr>
1735
+ </table>
1736
+ </div>
1737
+
1738
+ <div class="method_details ">
1739
+ <h3 class="signature " id="store_object-instance_method">
1740
+
1741
+ - (<tt>Object</tt>) <strong>store_object</strong>(handler, ops)
1742
+
1743
+
1744
+
1745
+
1746
+
1747
+ </h3><div class="docstring">
1748
+ <div class="discussion">
1749
+
1750
+ <p>:nodoc:</p>
1751
+
1752
+
1753
+ </div>
1754
+ </div>
1755
+ <div class="tags">
1756
+
1757
+
1758
+ </div><table class="source_code">
1759
+ <tr>
1760
+ <td>
1761
+ <pre class="lines">
1762
+
1763
+
1764
+ 132
1765
+ 133
1766
+ 134
1767
+ 135
1768
+ 136
1769
+ 137
1770
+ 138</pre>
1771
+ </td>
1772
+ <td>
1773
+ <pre class="code"><span class="info file"># File 'lib/bridge.rb', line 132</span>
1774
+
1775
+ <span class='kw'>def</span> <span class='id identifier rubyid_store_object'>store_object</span> <span class='id identifier rubyid_handler'>handler</span><span class='comma'>,</span> <span class='id identifier rubyid_ops'>ops</span> <span class='comment'>#:nodoc:
1776
+ </span> <span class='comment'># Generate random id for callback being stored
1777
+ </span> <span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='const'>Util</span><span class='period'>.</span><span class='id identifier rubyid_generate_guid'>generate_guid</span>
1778
+ <span class='ivar'>@store</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_handler'>handler</span>
1779
+ <span class='comment'># Return reference to stored callback
1780
+ </span> <span class='const'>Reference</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>client</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='ivar'>@connection</span><span class='period'>.</span><span class='id identifier rubyid_client_id'>client_id</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_ops'>ops</span><span class='rparen'>)</span>
1781
+ <span class='kw'>end</span></pre>
1782
+ </td>
1783
+ </tr>
1784
+ </table>
1785
+ </div>
1786
+
1787
+ <div class="method_details ">
1788
+ <h3 class="signature " id="unpublish_service-instance_method">
1789
+
1790
+ - (<tt>Object</tt>) <strong>unpublish_service</strong>(name, &amp;callback)
1791
+
1792
+
1793
+
1794
+
1795
+
1796
+ </h3><div class="docstring">
1797
+ <div class="discussion">
1798
+
1799
+ <p>:call-seq:</p>
1800
+
1801
+ <pre class="ruby"><span class="ruby-identifier">unpublish_service</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">handler</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span> <span class="ruby-identifier">block</span> }
1802
+ </pre>
1803
+
1804
+ <p>Stops publishing a ruby object or module as a Bridge service with the</p>
1805
+
1806
+ <pre class="code ruby"><code>given name.</code></pre>
1807
+
1808
+ <p>If a block is given, calls the given block with the name of the</p>
1809
+
1810
+ <pre class="code ruby"><code>unpublished service.</code></pre>
1811
+
1812
+ <h3 id="label-Attributes++">Attributes </h3>
1813
+ <dl class="rdoc-list note-list"><dt><code>name</code>
1814
+ <dd>
1815
+ <p>The name of the Bridge service that will no longer be</p>
1816
+ </dd></dl>
1817
+
1818
+ <pre class="code ruby"><code><span class='id identifier rubyid_published'>published</span></code></pre>
1819
+
1820
+
1821
+ </div>
1822
+ </div>
1823
+ <div class="tags">
1824
+
1825
+
1826
+ </div><table class="source_code">
1827
+ <tr>
1828
+ <td>
1829
+ <pre class="lines">
1830
+
1831
+
1832
+ 222
1833
+ 223
1834
+ 224
1835
+ 225
1836
+ 226
1837
+ 227
1838
+ 228
1839
+ 229
1840
+ 230
1841
+ 231
1842
+ 232</pre>
1843
+ </td>
1844
+ <td>
1845
+ <pre class="code"><span class="info file"># File 'lib/bridge.rb', line 222</span>
1846
+
1847
+ <span class='kw'>def</span> <span class='id identifier rubyid_unpublish_service'>unpublish_service</span> <span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_callback'>callback</span>
1848
+ <span class='kw'>if</span> <span class='id identifier rubyid_name'>name</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>system</span><span class='tstring_end'>'</span></span>
1849
+ <span class='const'>Util</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Invalid service name: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
1850
+ <span class='kw'>else</span>
1851
+ <span class='ivar'>@connection</span><span class='period'>.</span><span class='id identifier rubyid_send_command'>send_command</span><span class='lparen'>(</span>
1852
+ <span class='symbol'>:LEAVEWORKERPOOL</span><span class='comma'>,</span>
1853
+ <span class='lbrace'>{</span> <span class='symbol'>:name</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_name'>name</span><span class='comma'>,</span>
1854
+ <span class='symbol'>:callback</span> <span class='op'>=&gt;</span> <span class='const'>Serializer</span><span class='period'>.</span><span class='id identifier rubyid_serialize'>serialize</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_callback'>callback</span><span class='rparen'>)</span><span class='rbrace'>}</span>
1855
+ <span class='rparen'>)</span>
1856
+ <span class='kw'>end</span>
1857
+ <span class='kw'>end</span></pre>
1858
+ </td>
1859
+ </tr>
1860
+ </table>
1861
+ </div>
1862
+
1863
+ </div>
1864
+
1865
+ </div>
1866
+
1867
+ <div id="footer">
1868
+ Generated on Wed Jun 20 11:00:11 2012 by
1869
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1870
+ 0.8.2.1 (ruby-1.9.3).
1871
+ </div>
1872
+
1873
+ </body>
1874
+ </html>