bridge-ruby 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +19 -0
- data/README.md +31 -0
- data/Rakefile +24 -0
- data/bridge-ruby.gemspec +24 -0
- data/doc/Bridge.html +276 -0
- data/doc/Bridge/Bridge.html +1874 -0
- data/doc/Bridge/Bridge/SystemService.html +396 -0
- data/doc/Bridge/Client.html +271 -0
- data/doc/Bridge/Connection.html +1180 -0
- data/doc/Bridge/Connection/SockBuffer.html +322 -0
- data/doc/Bridge/Reference.html +605 -0
- data/doc/Bridge/Serializer.html +405 -0
- data/doc/Bridge/Serializer/Callback.html +498 -0
- data/doc/Bridge/Tcp.html +657 -0
- data/doc/Bridge/Util.html +643 -0
- data/doc/Bridge/Util/CallbackReference.html +557 -0
- data/doc/OpenSSL/X509/Certificate.html +275 -0
- data/doc/SSLCertificateVerification.html +446 -0
- data/doc/_index.html +239 -0
- data/doc/class_list.html +53 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +328 -0
- data/doc/file.README.html +106 -0
- data/doc/file_list.html +55 -0
- data/doc/frames.html +28 -0
- data/doc/index.html +106 -0
- data/doc/js/app.js +214 -0
- data/doc/js/full_list.js +173 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +772 -0
- data/doc/top-level-namespace.html +112 -0
- data/examples/channels/client-writeable.rb +24 -0
- data/examples/channels/client.rb +23 -0
- data/examples/channels/server.rb +24 -0
- data/examples/chat/chatclient.rb +21 -0
- data/examples/chat/chatserver.rb +24 -0
- data/examples/client-context/client.rb +21 -0
- data/examples/client-context/server.rb +25 -0
- data/examples/secure/example.rb +8 -0
- data/examples/simple/channels.rb +47 -0
- data/examples/simple/services.rb +41 -0
- data/include/ssl/cacert.pem +3331 -0
- data/lib/bridge-ruby.rb +441 -0
- data/lib/client.rb +14 -0
- data/lib/connection.rb +162 -0
- data/lib/reference.rb +49 -0
- data/lib/serializer.rb +104 -0
- data/lib/ssl_utils.rb +68 -0
- data/lib/tcp.rb +73 -0
- data/lib/util.rb +101 -0
- data/lib/version.rb +3 -0
- data/rakelib/package.rake +4 -0
- data/rakelib/test.rake +8 -0
- data/test/regression/reconnect.rb +48 -0
- data/test/regression/rpc.rb +39 -0
- data/test/regression/test.rb +58 -0
- data/test/unit/bridge_dummy.rb +26 -0
- data/test/unit/connection_dummy.rb +21 -0
- data/test/unit/reference_dummy.rb +11 -0
- data/test/unit/tcp_dummy.rb +12 -0
- data/test/unit/test.rb +20 -0
- data/test/unit/test_reference.rb +30 -0
- data/test/unit/test_serializer.rb +109 -0
- data/test/unit/test_tcp.rb +51 -0
- data/test/unit/test_util.rb +59 -0
- metadata +162 -0
data/doc/Bridge/Tcp.html
ADDED
@@ -0,0 +1,657 @@
|
|
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::Tcp
|
8
|
+
|
9
|
+
— 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 (T)</a> »
|
35
|
+
<span class='title'><span class='object_link'><a href="../Bridge.html" title="Bridge (module)">Bridge</a></span></span>
|
36
|
+
»
|
37
|
+
<span class="title">Tcp</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::Tcp
|
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">EventMachine::Connection</span>
|
77
|
+
|
78
|
+
<ul class="fullTree">
|
79
|
+
<li>Object</li>
|
80
|
+
|
81
|
+
<li class="next">EventMachine::Connection</li>
|
82
|
+
|
83
|
+
<li class="next">Bridge::Tcp</li>
|
84
|
+
|
85
|
+
</ul>
|
86
|
+
<a href="#" class="inheritanceTree">show all</a>
|
87
|
+
|
88
|
+
</dd>
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
<dt class="r2">Includes:</dt>
|
96
|
+
<dd class="r2"><span class='object_link'><a href="../SSLCertificateVerification.html" title="SSLCertificateVerification (module)">SSLCertificateVerification</a></span></dd>
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
<dt class="r1 last">Defined in:</dt>
|
103
|
+
<dd class="r1 last">lib/tcp.rb</dd>
|
104
|
+
|
105
|
+
</dl>
|
106
|
+
<div class="clear"></div>
|
107
|
+
|
108
|
+
<h2>Overview</h2><div class="docstring">
|
109
|
+
<div class="discussion">
|
110
|
+
|
111
|
+
<p>:nodoc: all</p>
|
112
|
+
|
113
|
+
|
114
|
+
</div>
|
115
|
+
</div>
|
116
|
+
<div class="tags">
|
117
|
+
|
118
|
+
|
119
|
+
</div>
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
<h2>
|
128
|
+
Instance Method Summary
|
129
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
130
|
+
</h2>
|
131
|
+
|
132
|
+
<ul class="summary">
|
133
|
+
|
134
|
+
<li class="public ">
|
135
|
+
<span class="summary_signature">
|
136
|
+
|
137
|
+
<a href="#connection_completed-instance_method" title="#connection_completed (instance method)">- (Object) <strong>connection_completed</strong> </a>
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
</span>
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
152
|
+
|
153
|
+
</li>
|
154
|
+
|
155
|
+
|
156
|
+
<li class="public ">
|
157
|
+
<span class="summary_signature">
|
158
|
+
|
159
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">- (Tcp) <strong>initialize</strong>(connection) </a>
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
</span>
|
164
|
+
|
165
|
+
|
166
|
+
<span class="note title constructor">constructor</span>
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
<span class="summary_desc"><div class='inline'>
|
176
|
+
<p>A new instance of Tcp.</p>
|
177
|
+
</div></span>
|
178
|
+
|
179
|
+
</li>
|
180
|
+
|
181
|
+
|
182
|
+
<li class="public ">
|
183
|
+
<span class="summary_signature">
|
184
|
+
|
185
|
+
<a href="#post_init-instance_method" title="#post_init (instance method)">- (Object) <strong>post_init</strong> </a>
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
</span>
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
200
|
+
|
201
|
+
</li>
|
202
|
+
|
203
|
+
|
204
|
+
<li class="public ">
|
205
|
+
<span class="summary_signature">
|
206
|
+
|
207
|
+
<a href="#read-instance_method" title="#read (instance method)">- (Object) <strong>read</strong>(len, &cb) </a>
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
</span>
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
222
|
+
|
223
|
+
</li>
|
224
|
+
|
225
|
+
|
226
|
+
<li class="public ">
|
227
|
+
<span class="summary_signature">
|
228
|
+
|
229
|
+
<a href="#receive_data-instance_method" title="#receive_data (instance method)">- (Object) <strong>receive_data</strong>(data) </a>
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
</span>
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
244
|
+
|
245
|
+
</li>
|
246
|
+
|
247
|
+
|
248
|
+
<li class="public ">
|
249
|
+
<span class="summary_signature">
|
250
|
+
|
251
|
+
<a href="#send-instance_method" title="#send (instance method)">- (Object) <strong>send</strong>(arg) </a>
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
</span>
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
266
|
+
|
267
|
+
</li>
|
268
|
+
|
269
|
+
|
270
|
+
<li class="public ">
|
271
|
+
<span class="summary_signature">
|
272
|
+
|
273
|
+
<a href="#start-instance_method" title="#start (instance method)">- (Object) <strong>start</strong> </a>
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
</span>
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
288
|
+
|
289
|
+
</li>
|
290
|
+
|
291
|
+
|
292
|
+
<li class="public ">
|
293
|
+
<span class="summary_signature">
|
294
|
+
|
295
|
+
<a href="#unbind-instance_method" title="#unbind (instance method)">- (Object) <strong>unbind</strong> </a>
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
</span>
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
310
|
+
|
311
|
+
</li>
|
312
|
+
|
313
|
+
|
314
|
+
</ul>
|
315
|
+
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
<h3 class="inherited">Methods included from <span class='object_link'><a href="../SSLCertificateVerification.html" title="SSLCertificateVerification (module)">SSLCertificateVerification</a></span></h3>
|
327
|
+
<p class="inherited"><span class='object_link'><a href="../SSLCertificateVerification.html#ca_store-instance_method" title="SSLCertificateVerification#ca_store (method)">#ca_store</a></span>, <span class='object_link'><a href="../SSLCertificateVerification.html#ssl_handshake_completed-instance_method" title="SSLCertificateVerification#ssl_handshake_completed (method)">#ssl_handshake_completed</a></span>, <span class='object_link'><a href="../SSLCertificateVerification.html#ssl_verify_peer-instance_method" title="SSLCertificateVerification#ssl_verify_peer (method)">#ssl_verify_peer</a></span></p>
|
328
|
+
|
329
|
+
<div id="constructor_details" class="method_details_list">
|
330
|
+
<h2>Constructor Details</h2>
|
331
|
+
|
332
|
+
<div class="method_details first">
|
333
|
+
<h3 class="signature first" id="initialize-instance_method">
|
334
|
+
|
335
|
+
- (<tt><span class='object_link'><a href="" title="Bridge::Tcp (class)">Tcp</a></span></tt>) <strong>initialize</strong>(connection)
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
</h3><div class="docstring">
|
342
|
+
<div class="discussion">
|
343
|
+
|
344
|
+
<p>A new instance of Tcp</p>
|
345
|
+
|
346
|
+
|
347
|
+
</div>
|
348
|
+
</div>
|
349
|
+
<div class="tags">
|
350
|
+
|
351
|
+
|
352
|
+
</div><table class="source_code">
|
353
|
+
<tr>
|
354
|
+
<td>
|
355
|
+
<pre class="lines">
|
356
|
+
|
357
|
+
|
358
|
+
10
|
359
|
+
11
|
360
|
+
12
|
361
|
+
13
|
362
|
+
14
|
363
|
+
15
|
364
|
+
16
|
365
|
+
17
|
366
|
+
18</pre>
|
367
|
+
</td>
|
368
|
+
<td>
|
369
|
+
<pre class="code"><span class="info file"># File 'lib/tcp.rb', line 10</span>
|
370
|
+
|
371
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span> <span class='id identifier rubyid_connection'>connection</span>
|
372
|
+
<span class='ivar'>@buffer</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span>
|
373
|
+
<span class='ivar'>@len</span> <span class='op'>=</span> <span class='int'>0</span>
|
374
|
+
<span class='ivar'>@pos</span> <span class='op'>=</span> <span class='int'>0</span>
|
375
|
+
<span class='ivar'>@callback</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
376
|
+
<span class='ivar'>@connection</span> <span class='op'>=</span> <span class='id identifier rubyid_connection'>connection</span>
|
377
|
+
<span class='const'>SSLCertificateVerification</span><span class='period'>.</span><span class='id identifier rubyid_ca_cert_file'>ca_cert_file</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_expand_path'>expand_path</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>../../include/ssl/cacert.pem</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='kw'>__FILE__</span><span class='rparen'>)</span>
|
378
|
+
<span class='id identifier rubyid_start'>start</span>
|
379
|
+
<span class='kw'>end</span></pre>
|
380
|
+
</td>
|
381
|
+
</tr>
|
382
|
+
</table>
|
383
|
+
</div>
|
384
|
+
|
385
|
+
</div>
|
386
|
+
|
387
|
+
|
388
|
+
<div id="instance_method_details" class="method_details_list">
|
389
|
+
<h2>Instance Method Details</h2>
|
390
|
+
|
391
|
+
|
392
|
+
<div class="method_details first">
|
393
|
+
<h3 class="signature first" id="connection_completed-instance_method">
|
394
|
+
|
395
|
+
- (<tt>Object</tt>) <strong>connection_completed</strong>
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
</h3><table class="source_code">
|
402
|
+
<tr>
|
403
|
+
<td>
|
404
|
+
<pre class="lines">
|
405
|
+
|
406
|
+
|
407
|
+
24
|
408
|
+
25
|
409
|
+
26
|
410
|
+
27</pre>
|
411
|
+
</td>
|
412
|
+
<td>
|
413
|
+
<pre class="code"><span class="info file"># File 'lib/tcp.rb', line 24</span>
|
414
|
+
|
415
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_connection_completed'>connection_completed</span>
|
416
|
+
<span class='comment'># connection now ready. call the callback
|
417
|
+
</span> <span class='ivar'>@connection</span><span class='period'>.</span><span class='id identifier rubyid_onopen'>onopen</span> <span class='kw'>self</span>
|
418
|
+
<span class='kw'>end</span></pre>
|
419
|
+
</td>
|
420
|
+
</tr>
|
421
|
+
</table>
|
422
|
+
</div>
|
423
|
+
|
424
|
+
<div class="method_details ">
|
425
|
+
<h3 class="signature " id="post_init-instance_method">
|
426
|
+
|
427
|
+
- (<tt>Object</tt>) <strong>post_init</strong>
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
</h3><table class="source_code">
|
434
|
+
<tr>
|
435
|
+
<td>
|
436
|
+
<pre class="lines">
|
437
|
+
|
438
|
+
|
439
|
+
20
|
440
|
+
21
|
441
|
+
22</pre>
|
442
|
+
</td>
|
443
|
+
<td>
|
444
|
+
<pre class="code"><span class="info file"># File 'lib/tcp.rb', line 20</span>
|
445
|
+
|
446
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_post_init'>post_init</span>
|
447
|
+
<span class='id identifier rubyid_start_tls'>start_tls</span><span class='lparen'>(</span><span class='symbol'>:verify_peer</span> <span class='op'>=></span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='ivar'>@connection</span><span class='period'>.</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:secure</span><span class='rbracket'>]</span>
|
448
|
+
<span class='kw'>end</span></pre>
|
449
|
+
</td>
|
450
|
+
</tr>
|
451
|
+
</table>
|
452
|
+
</div>
|
453
|
+
|
454
|
+
<div class="method_details ">
|
455
|
+
<h3 class="signature " id="read-instance_method">
|
456
|
+
|
457
|
+
- (<tt>Object</tt>) <strong>read</strong>(len, &cb)
|
458
|
+
|
459
|
+
|
460
|
+
|
461
|
+
|
462
|
+
|
463
|
+
</h3><table class="source_code">
|
464
|
+
<tr>
|
465
|
+
<td>
|
466
|
+
<pre class="lines">
|
467
|
+
|
468
|
+
|
469
|
+
41
|
470
|
+
42
|
471
|
+
43
|
472
|
+
44
|
473
|
+
45
|
474
|
+
46</pre>
|
475
|
+
</td>
|
476
|
+
<td>
|
477
|
+
<pre class="code"><span class="info file"># File 'lib/tcp.rb', line 41</span>
|
478
|
+
|
479
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_read'>read</span> <span class='id identifier rubyid_len'>len</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_cb'>cb</span>
|
480
|
+
<span class='ivar'>@buffer</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span>
|
481
|
+
<span class='ivar'>@len</span> <span class='op'>=</span> <span class='id identifier rubyid_len'>len</span>
|
482
|
+
<span class='ivar'>@pos</span> <span class='op'>=</span> <span class='int'>0</span>
|
483
|
+
<span class='ivar'>@callback</span> <span class='op'>=</span> <span class='id identifier rubyid_cb'>cb</span>
|
484
|
+
<span class='kw'>end</span></pre>
|
485
|
+
</td>
|
486
|
+
</tr>
|
487
|
+
</table>
|
488
|
+
</div>
|
489
|
+
|
490
|
+
<div class="method_details ">
|
491
|
+
<h3 class="signature " id="receive_data-instance_method">
|
492
|
+
|
493
|
+
- (<tt>Object</tt>) <strong>receive_data</strong>(data)
|
494
|
+
|
495
|
+
|
496
|
+
|
497
|
+
|
498
|
+
|
499
|
+
</h3><table class="source_code">
|
500
|
+
<tr>
|
501
|
+
<td>
|
502
|
+
<pre class="lines">
|
503
|
+
|
504
|
+
|
505
|
+
29
|
506
|
+
30
|
507
|
+
31
|
508
|
+
32
|
509
|
+
33
|
510
|
+
34
|
511
|
+
35
|
512
|
+
36
|
513
|
+
37
|
514
|
+
38
|
515
|
+
39</pre>
|
516
|
+
</td>
|
517
|
+
<td>
|
518
|
+
<pre class="code"><span class="info file"># File 'lib/tcp.rb', line 29</span>
|
519
|
+
|
520
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_receive_data'>receive_data</span> <span class='id identifier rubyid_data'>data</span>
|
521
|
+
<span class='id identifier rubyid_left'>left</span> <span class='op'>=</span> <span class='ivar'>@len</span> <span class='op'>-</span> <span class='ivar'>@pos</span>
|
522
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span> <span class='op'>>=</span> <span class='id identifier rubyid_left'>left</span>
|
523
|
+
<span class='ivar'>@buffer</span> <span class='op'><<</span> <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_slice'>slice</span><span class='lparen'>(</span><span class='int'>0</span><span class='comma'>,</span> <span class='id identifier rubyid_left'>left</span><span class='rparen'>)</span>
|
524
|
+
<span class='ivar'>@callback</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span> <span class='ivar'>@buffer</span>
|
525
|
+
<span class='id identifier rubyid_receive_data'>receive_data</span> <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_slice'>slice</span><span class='lparen'>(</span><span class='id identifier rubyid_left'>left</span><span class='op'>..</span><span class='op'>-</span><span class='int'>1</span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
526
|
+
<span class='kw'>else</span>
|
527
|
+
<span class='ivar'>@buffer</span> <span class='op'><<</span> <span class='id identifier rubyid_data'>data</span>
|
528
|
+
<span class='ivar'>@pos</span> <span class='op'>=</span> <span class='ivar'>@pos</span> <span class='op'>+</span> <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span>
|
529
|
+
<span class='kw'>end</span>
|
530
|
+
<span class='kw'>end</span></pre>
|
531
|
+
</td>
|
532
|
+
</tr>
|
533
|
+
</table>
|
534
|
+
</div>
|
535
|
+
|
536
|
+
<div class="method_details ">
|
537
|
+
<h3 class="signature " id="send-instance_method">
|
538
|
+
|
539
|
+
- (<tt>Object</tt>) <strong>send</strong>(arg)
|
540
|
+
|
541
|
+
|
542
|
+
|
543
|
+
|
544
|
+
|
545
|
+
</h3><table class="source_code">
|
546
|
+
<tr>
|
547
|
+
<td>
|
548
|
+
<pre class="lines">
|
549
|
+
|
550
|
+
|
551
|
+
61
|
552
|
+
62
|
553
|
+
63
|
554
|
+
64</pre>
|
555
|
+
</td>
|
556
|
+
<td>
|
557
|
+
<pre class="code"><span class="info file"># File 'lib/tcp.rb', line 61</span>
|
558
|
+
|
559
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_send'>send</span> <span class='id identifier rubyid_arg'>arg</span>
|
560
|
+
<span class='comment'># Prepend length header to message
|
561
|
+
</span> <span class='id identifier rubyid_send_data'>send_data</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='id identifier rubyid_arg'>arg</span><span class='period'>.</span><span class='id identifier rubyid_length'>length</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_pack'>pack</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>N</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='op'>+</span> <span class='id identifier rubyid_arg'>arg</span><span class='rparen'>)</span>
|
562
|
+
<span class='kw'>end</span></pre>
|
563
|
+
</td>
|
564
|
+
</tr>
|
565
|
+
</table>
|
566
|
+
</div>
|
567
|
+
|
568
|
+
<div class="method_details ">
|
569
|
+
<h3 class="signature " id="start-instance_method">
|
570
|
+
|
571
|
+
- (<tt>Object</tt>) <strong>start</strong>
|
572
|
+
|
573
|
+
|
574
|
+
|
575
|
+
|
576
|
+
|
577
|
+
</h3><table class="source_code">
|
578
|
+
<tr>
|
579
|
+
<td>
|
580
|
+
<pre class="lines">
|
581
|
+
|
582
|
+
|
583
|
+
48
|
584
|
+
49
|
585
|
+
50
|
586
|
+
51
|
587
|
+
52
|
588
|
+
53
|
589
|
+
54
|
590
|
+
55
|
591
|
+
56
|
592
|
+
57
|
593
|
+
58
|
594
|
+
59</pre>
|
595
|
+
</td>
|
596
|
+
<td>
|
597
|
+
<pre class="code"><span class="info file"># File 'lib/tcp.rb', line 48</span>
|
598
|
+
|
599
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_start'>start</span>
|
600
|
+
<span class='comment'># Read header bytes
|
601
|
+
</span> <span class='id identifier rubyid_read'>read</span> <span class='int'>4</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_data'>data</span><span class='op'>|</span>
|
602
|
+
<span class='comment'># Read body bytes
|
603
|
+
</span> <span class='id identifier rubyid_read'>read</span> <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_unpack'>unpack</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>N</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_data'>data</span><span class='op'>|</span>
|
604
|
+
<span class='comment'># Call message handler
|
605
|
+
</span> <span class='ivar'>@connection</span><span class='period'>.</span><span class='id identifier rubyid_onmessage'>onmessage</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='symbol'>:data</span> <span class='op'>=></span> <span class='id identifier rubyid_data'>data</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='kw'>self</span><span class='rparen'>)</span>
|
606
|
+
<span class='comment'># Await next message
|
607
|
+
</span> <span class='id identifier rubyid_start'>start</span>
|
608
|
+
<span class='kw'>end</span>
|
609
|
+
<span class='kw'>end</span>
|
610
|
+
<span class='kw'>end</span></pre>
|
611
|
+
</td>
|
612
|
+
</tr>
|
613
|
+
</table>
|
614
|
+
</div>
|
615
|
+
|
616
|
+
<div class="method_details ">
|
617
|
+
<h3 class="signature " id="unbind-instance_method">
|
618
|
+
|
619
|
+
- (<tt>Object</tt>) <strong>unbind</strong>
|
620
|
+
|
621
|
+
|
622
|
+
|
623
|
+
|
624
|
+
|
625
|
+
</h3><table class="source_code">
|
626
|
+
<tr>
|
627
|
+
<td>
|
628
|
+
<pre class="lines">
|
629
|
+
|
630
|
+
|
631
|
+
66
|
632
|
+
67
|
633
|
+
68</pre>
|
634
|
+
</td>
|
635
|
+
<td>
|
636
|
+
<pre class="code"><span class="info file"># File 'lib/tcp.rb', line 66</span>
|
637
|
+
|
638
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_unbind'>unbind</span>
|
639
|
+
<span class='ivar'>@connection</span><span class='period'>.</span><span class='id identifier rubyid_onclose'>onclose</span>
|
640
|
+
<span class='kw'>end</span></pre>
|
641
|
+
</td>
|
642
|
+
</tr>
|
643
|
+
</table>
|
644
|
+
</div>
|
645
|
+
|
646
|
+
</div>
|
647
|
+
|
648
|
+
</div>
|
649
|
+
|
650
|
+
<div id="footer">
|
651
|
+
Generated on Wed Jun 20 11:00:11 2012 by
|
652
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
653
|
+
0.8.2.1 (ruby-1.9.3).
|
654
|
+
</div>
|
655
|
+
|
656
|
+
</body>
|
657
|
+
</html>
|