ionian 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: db558844affd07c0e6ce023a2a0f693fafd2941b
4
- data.tar.gz: 2dbf02d003ccbc1bd0d1d72673c30e1899a858fc
3
+ metadata.gz: 964e038d726e1d4df50ee1d0bc9a12efcc48ddfe
4
+ data.tar.gz: f277619e42d62b1fbd764cb3ed2130fd69f4edd4
5
5
  SHA512:
6
- metadata.gz: 31aac7428abf9374504ad52eb3a2ba62391a1d236d37bf3079fc69e35e14aed87a49516930a698f307047ad8dd86d0359d37636617f60a380ce676275ad9f665
7
- data.tar.gz: d704c89f7df1e0e11baa46a785cbfa3b89d3cddfd219f7eaf5eb2d3159f63daeba0f4ab05df3a015b71797b5ea2b8b2ba158838ea36a3f0c7c1ecd4377b84888
6
+ metadata.gz: 7a3eabd8146f2317a6594ea9260232bb49664ddcb50d38ad2f4b9d0e96025b58c7f974c67594323ea9ad7e4f66faf8bad5e31e55162f905efeb54b6c40558b80
7
+ data.tar.gz: df0226142d2dbd26ecceb16628745a66d4f31a0c5c6bd0125dc42b93138fbb415b986a59471cb11d891f6c14b7ef79d67094f88247ac1768b6ec7c91c5c65bd8
@@ -24,16 +24,16 @@
24
24
  <body id="top" role="document" class="module">
25
25
  <nav role="navigation">
26
26
  <div id="project-navigation">
27
- <div id="home-section" role="banner" class="nav-section">
27
+ <div id="home-section" role="region" title="Quick navigation" class="nav-section">
28
28
  <h2>
29
29
  <a href="../../index.html" rel="home">Home</a>
30
30
  </h2>
31
31
 
32
- <h3>
32
+ <div id="table-of-contents-navigation">
33
33
  <a href="../../table_of_contents.html#pages">Pages</a>
34
34
  <a href="../../table_of_contents.html#classes">Classes</a>
35
35
  <a href="../../table_of_contents.html#methods">Methods</a>
36
- </h3>
36
+ </div>
37
37
  </div>
38
38
 
39
39
  <div id="search-section" role="search" class="project-section initially-hidden">
@@ -41,14 +41,13 @@
41
41
  <div id="search-field-wrapper">
42
42
  <input id="search-field" role="combobox" aria-label="Search"
43
43
  aria-autocomplete="list" aria-controls="search-results"
44
- type="text" name="search" placeholder="Search"
44
+ type="text" name="search" placeholder="Search" spellcheck="false"
45
45
  title="Type to search, Up and Down to navigate, Enter to load">
46
46
  </div>
47
47
 
48
48
  <ul id="search-results" aria-label="Search Results"
49
49
  aria-busy="false" aria-expanded="false"
50
- aria-atomic="false" aria-live="polite"
51
- aria-relevant="all" class="initially-hidden"></ul>
50
+ aria-atomic="false" class="initially-hidden"></ul>
52
51
  </form>
53
52
  </div>
54
53
 
@@ -81,6 +80,8 @@
81
80
 
82
81
  <li ><a href="#method-i-purge">#purge</a>
83
82
 
83
+ <li ><a href="#method-i-read_all">#read_all</a>
84
+
84
85
  <li ><a href="#method-i-read_match">#read_match</a>
85
86
 
86
87
  <li ><a href="#method-i-register_observer">#register_observer</a>
@@ -389,7 +390,7 @@ automatically.</p>
389
390
 
390
391
 
391
392
  <div class="method-source-code" id="purge-source">
392
- <pre><span class="ruby-comment"># File lib/ionian/extension/io.rb, line 137</span>
393
+ <pre><span class="ruby-comment"># File lib/ionian/extension/io.rb, line 143</span>
393
394
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">purge</span>
394
395
  <span class="ruby-comment"># Erase IO buffer.</span>
395
396
  <span class="ruby-keyword">while</span> <span class="ruby-operator">::</span><span class="ruby-constant">IO</span>.<span class="ruby-identifier">select</span> [<span class="ruby-keyword">self</span>], <span class="ruby-keyword">nil</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-value">0</span>
@@ -405,6 +406,40 @@ automatically.</p>
405
406
 
406
407
 
407
408
 
409
+ </div>
410
+
411
+
412
+ <div id="method-i-read_all" class="method-detail ">
413
+
414
+ <div class="method-heading">
415
+ <span class="method-name">read_all</span><span
416
+ class="method-args">()</span>
417
+
418
+ <span class="method-click-advice">click to toggle source</span>
419
+
420
+ </div>
421
+
422
+
423
+ <div class="method-description">
424
+
425
+ <p>Read all data in the buffer. An alternative to using readpartial with a
426
+ large length.</p>
427
+
428
+
429
+
430
+
431
+ <div class="method-source-code" id="read_all-source">
432
+ <pre><span class="ruby-comment"># File lib/ionian/extension/io.rb, line 56</span>
433
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">read_all</span>
434
+ <span class="ruby-identifier">readpartial</span> <span class="ruby-value">0xFFFF</span>
435
+ <span class="ruby-keyword">end</span></pre>
436
+ </div>
437
+
438
+ </div>
439
+
440
+
441
+
442
+
408
443
  </div>
409
444
 
410
445
 
@@ -443,14 +478,14 @@ helpful for protocols like RS232 that do not have packet boundries.</p>
443
478
  <pre>timeout: Timeout in seconds IO::select will block.
444
479
  skip_select: Skip over the IO::select statement. Use if you
445
480
  are calling IO::select ahead of this method.
446
- build_methods: Build method accessors from named captures.
481
+ build_methods: Build accessor methods from named capture groups.
447
482
  Enabled by default.</pre>
448
483
 
449
484
 
450
485
 
451
486
 
452
487
  <div class="method-source-code" id="read_match-source">
453
- <pre><span class="ruby-comment"># File lib/ionian/extension/io.rb, line 77</span>
488
+ <pre><span class="ruby-comment"># File lib/ionian/extension/io.rb, line 83</span>
454
489
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">read_match</span>(<span class="ruby-operator">**</span><span class="ruby-identifier">kwargs</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
455
490
  <span class="ruby-identifier">timeout</span> = <span class="ruby-identifier">kwargs</span>.<span class="ruby-identifier">fetch</span> <span class="ruby-value">:timeout</span>, <span class="ruby-ivar">@ionian_timeout</span>
456
491
  <span class="ruby-identifier">skip_select</span> = <span class="ruby-identifier">kwargs</span>.<span class="ruby-identifier">fetch</span> <span class="ruby-value">:skip_select</span>, <span class="ruby-ivar">@ionian_skip_select</span>
@@ -520,7 +555,7 @@ ionian_socket.register_observer {…}</p>
520
555
 
521
556
 
522
557
  <div class="method-source-code" id="register_observer-source">
523
- <pre><span class="ruby-comment"># File lib/ionian/extension/io.rb, line 150</span>
558
+ <pre><span class="ruby-comment"># File lib/ionian/extension/io.rb, line 156</span>
524
559
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">register_observer</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
525
560
  <span class="ruby-ivar">@ionian_listeners</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">block</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@ionian_listeners</span>.<span class="ruby-identifier">include?</span> <span class="ruby-identifier">block</span>
526
561
  <span class="ruby-identifier">block</span>
@@ -561,7 +596,7 @@ be used if <a href="IO.html#method-i-read_match">read_match</a> is used.</p>
561
596
 
562
597
 
563
598
  <div class="method-source-code" id="run_match-source">
564
- <pre><span class="ruby-comment"># File lib/ionian/extension/io.rb, line 118</span>
599
+ <pre><span class="ruby-comment"># File lib/ionian/extension/io.rb, line 124</span>
565
600
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">run_match</span>(<span class="ruby-operator">**</span><span class="ruby-identifier">kwargs</span>)
566
601
  <span class="ruby-ivar">@match_listener</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span>
567
602
  <span class="ruby-keyword">begin</span>
@@ -607,7 +642,7 @@ be used if <a href="IO.html#method-i-read_match">read_match</a> is used.</p>
607
642
 
608
643
 
609
644
  <div class="method-source-code" id="unregister_observer-source">
610
- <pre><span class="ruby-comment"># File lib/ionian/extension/io.rb, line 158</span>
645
+ <pre><span class="ruby-comment"># File lib/ionian/extension/io.rb, line 164</span>
611
646
  <span class="ruby-keyword">def</span> <span class="ruby-identifier">unregister_observer</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
612
647
  <span class="ruby-ivar">@ionian_listeners</span>.<span class="ruby-identifier">delete_if</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">o</span><span class="ruby-operator">|</span> <span class="ruby-identifier">o</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">block</span>}
613
648
  <span class="ruby-identifier">block</span>
@@ -630,7 +665,7 @@ be used if <a href="IO.html#method-i-read_match">read_match</a> is used.</p>
630
665
 
631
666
  <footer id="validator-badges" role="contentinfo">
632
667
  <p><a href="http://validator.w3.org/check/referer">Validate</a>
633
- <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.0.preview.1.
668
+ <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.0.
634
669
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
635
670
  </footer>
636
671
 
@@ -24,16 +24,16 @@
24
24
  <body id="top" role="document" class="module">
25
25
  <nav role="navigation">
26
26
  <div id="project-navigation">
27
- <div id="home-section" role="banner" class="nav-section">
27
+ <div id="home-section" role="region" title="Quick navigation" class="nav-section">
28
28
  <h2>
29
29
  <a href="../../index.html" rel="home">Home</a>
30
30
  </h2>
31
31
 
32
- <h3>
32
+ <div id="table-of-contents-navigation">
33
33
  <a href="../../table_of_contents.html#pages">Pages</a>
34
34
  <a href="../../table_of_contents.html#classes">Classes</a>
35
35
  <a href="../../table_of_contents.html#methods">Methods</a>
36
- </h3>
36
+ </div>
37
37
  </div>
38
38
 
39
39
  <div id="search-section" role="search" class="project-section initially-hidden">
@@ -41,14 +41,13 @@
41
41
  <div id="search-field-wrapper">
42
42
  <input id="search-field" role="combobox" aria-label="Search"
43
43
  aria-autocomplete="list" aria-controls="search-results"
44
- type="text" name="search" placeholder="Search"
44
+ type="text" name="search" placeholder="Search" spellcheck="false"
45
45
  title="Type to search, Up and Down to navigate, Enter to load">
46
46
  </div>
47
47
 
48
48
  <ul id="search-results" aria-label="Search Results"
49
49
  aria-busy="false" aria-expanded="false"
50
- aria-atomic="false" aria-live="polite"
51
- aria-relevant="all" class="initially-hidden"></ul>
50
+ aria-atomic="false" class="initially-hidden"></ul>
52
51
  </form>
53
52
  </div>
54
53
 
@@ -1405,7 +1404,7 @@ IP_MULTICAST_TTL )</p>
1405
1404
 
1406
1405
  <footer id="validator-badges" role="contentinfo">
1407
1406
  <p><a href="http://validator.w3.org/check/referer">Validate</a>
1408
- <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.0.preview.1.
1407
+ <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.0.
1409
1408
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
1410
1409
  </footer>
1411
1410
 
@@ -24,16 +24,16 @@
24
24
  <body id="top" role="document" class="module">
25
25
  <nav role="navigation">
26
26
  <div id="project-navigation">
27
- <div id="home-section" role="banner" class="nav-section">
27
+ <div id="home-section" role="region" title="Quick navigation" class="nav-section">
28
28
  <h2>
29
29
  <a href="../index.html" rel="home">Home</a>
30
30
  </h2>
31
31
 
32
- <h3>
32
+ <div id="table-of-contents-navigation">
33
33
  <a href="../table_of_contents.html#pages">Pages</a>
34
34
  <a href="../table_of_contents.html#classes">Classes</a>
35
35
  <a href="../table_of_contents.html#methods">Methods</a>
36
- </h3>
36
+ </div>
37
37
  </div>
38
38
 
39
39
  <div id="search-section" role="search" class="project-section initially-hidden">
@@ -41,14 +41,13 @@
41
41
  <div id="search-field-wrapper">
42
42
  <input id="search-field" role="combobox" aria-label="Search"
43
43
  aria-autocomplete="list" aria-controls="search-results"
44
- type="text" name="search" placeholder="Search"
44
+ type="text" name="search" placeholder="Search" spellcheck="false"
45
45
  title="Type to search, Up and Down to navigate, Enter to load">
46
46
  </div>
47
47
 
48
48
  <ul id="search-results" aria-label="Search Results"
49
49
  aria-busy="false" aria-expanded="false"
50
- aria-atomic="false" aria-live="polite"
51
- aria-relevant="all" class="initially-hidden"></ul>
50
+ aria-atomic="false" class="initially-hidden"></ul>
52
51
  </form>
53
52
  </div>
54
53
 
@@ -95,7 +94,7 @@
95
94
 
96
95
  <footer id="validator-badges" role="contentinfo">
97
96
  <p><a href="http://validator.w3.org/check/referer">Validate</a>
98
- <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.0.preview.1.
97
+ <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.0.
99
98
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
100
99
  </footer>
101
100
 
@@ -0,0 +1,389 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>class Ionian::Server - RDoc Documentation</title>
8
+
9
+ <link href="../fonts.css" rel="stylesheet">
10
+ <link href="../rdoc.css" rel="stylesheet">
11
+
12
+ <script type="text/javascript">
13
+ var rdoc_rel_prefix = "../";
14
+ </script>
15
+
16
+ <script src="../js/jquery.js"></script>
17
+ <script src="../js/navigation.js"></script>
18
+ <script src="../js/search_index.js"></script>
19
+ <script src="../js/search.js"></script>
20
+ <script src="../js/searcher.js"></script>
21
+ <script src="../js/darkfish.js"></script>
22
+
23
+
24
+ <body id="top" role="document" class="class">
25
+ <nav role="navigation">
26
+ <div id="project-navigation">
27
+ <div id="home-section" role="region" title="Quick navigation" class="nav-section">
28
+ <h2>
29
+ <a href="../index.html" rel="home">Home</a>
30
+ </h2>
31
+
32
+ <div id="table-of-contents-navigation">
33
+ <a href="../table_of_contents.html#pages">Pages</a>
34
+ <a href="../table_of_contents.html#classes">Classes</a>
35
+ <a href="../table_of_contents.html#methods">Methods</a>
36
+ </div>
37
+ </div>
38
+
39
+ <div id="search-section" role="search" class="project-section initially-hidden">
40
+ <form action="#" method="get" accept-charset="utf-8">
41
+ <div id="search-field-wrapper">
42
+ <input id="search-field" role="combobox" aria-label="Search"
43
+ aria-autocomplete="list" aria-controls="search-results"
44
+ type="text" name="search" placeholder="Search" spellcheck="false"
45
+ title="Type to search, Up and Down to navigate, Enter to load">
46
+ </div>
47
+
48
+ <ul id="search-results" aria-label="Search Results"
49
+ aria-busy="false" aria-expanded="false"
50
+ aria-atomic="false" class="initially-hidden"></ul>
51
+ </form>
52
+ </div>
53
+
54
+ </div>
55
+
56
+
57
+
58
+ <div id="class-metadata">
59
+
60
+ <div id="parent-class-section" class="nav-section">
61
+ <h3>Parent</h3>
62
+
63
+
64
+ <p class="link">Object
65
+
66
+ </div>
67
+
68
+
69
+
70
+ <!-- Method Quickref -->
71
+ <div id="method-list-section" class="nav-section">
72
+ <h3>Methods</h3>
73
+
74
+ <ul class="link-list" role="directory">
75
+
76
+ <li ><a href="#method-c-new">::new</a>
77
+
78
+ <li ><a href="#method-i-close">#close</a>
79
+
80
+ <li ><a href="#method-i-listen">#listen</a>
81
+
82
+ <li ><a href="#method-i-on_accept">#on_accept</a>
83
+
84
+ <li ><a href="#method-i-register_accept_listener">#register_accept_listener</a>
85
+
86
+ <li ><a href="#method-i-unregister_accept_listener">#unregister_accept_listener</a>
87
+
88
+ </ul>
89
+ </div>
90
+
91
+ </div>
92
+ </nav>
93
+
94
+ <main role="main" aria-labelledby="class-Ionian::Server">
95
+ <h1 id="class-Ionian::Server" class="class">
96
+ class Ionian::Server
97
+ </h1>
98
+
99
+ <section class="description">
100
+
101
+ <p>A convenient wrapper for TCP, UDP, and Unix server sockets.</p>
102
+
103
+ </section>
104
+
105
+
106
+
107
+
108
+ <section id="5Buntitled-5D" class="documentation-section">
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+ <section id="public-class-5Buntitled-5D-method-details" class="method-section">
119
+ <header>
120
+ <h3>Public Class Methods</h3>
121
+ </header>
122
+
123
+
124
+ <div id="method-c-new" class="method-detail ">
125
+
126
+ <div class="method-heading">
127
+ <span class="method-name">new</span><span
128
+ class="method-args">(**kwargs, &block)</span>
129
+
130
+ <span class="method-click-advice">click to toggle source</span>
131
+
132
+ </div>
133
+
134
+
135
+ <div class="method-description">
136
+
137
+
138
+
139
+
140
+
141
+
142
+ <div class="method-source-code" id="new-source">
143
+ <pre><span class="ruby-comment"># File lib/ionian/server.rb, line 9</span>
144
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span> <span class="ruby-operator">**</span><span class="ruby-identifier">kwargs</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
145
+ <span class="ruby-ivar">@accept_listeners</span> = []
146
+ <span class="ruby-identifier">register_accept_listener</span> <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">block_given?</span>
147
+
148
+ <span class="ruby-ivar">@interface</span> = <span class="ruby-identifier">kwargs</span>.<span class="ruby-identifier">fetch</span> <span class="ruby-value">:interface</span>, <span class="ruby-string">&#39;&#39;</span>
149
+ <span class="ruby-ivar">@port</span> = <span class="ruby-identifier">kwargs</span>.<span class="ruby-identifier">fetch</span> <span class="ruby-value">:port</span>, <span class="ruby-keyword">nil</span>
150
+
151
+
152
+ <span class="ruby-comment"># Automatically select UDP for the multicast range. Otherwise default to TCP.</span>
153
+ <span class="ruby-identifier">default_protocol</span> = <span class="ruby-value">:tcp</span>
154
+ <span class="ruby-comment"># TODO: This ivar may be incorrect for UDP -- bound interface is not destination.</span>
155
+ <span class="ruby-identifier">default_protocol</span> = <span class="ruby-value">:udp</span> <span class="ruby-keyword">if</span> <span class="ruby-constant">Ionian</span><span class="ruby-operator">::</span><span class="ruby-constant">Extension</span><span class="ruby-operator">::</span><span class="ruby-constant">Socket</span>.<span class="ruby-identifier">multicast?</span> <span class="ruby-ivar">@interface</span>
156
+ <span class="ruby-identifier">default_protocol</span> = <span class="ruby-value">:unix</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@interface</span>.<span class="ruby-identifier">start_with?</span> <span class="ruby-string">&#39;/&#39;</span>
157
+
158
+ <span class="ruby-ivar">@protocol</span> = <span class="ruby-identifier">kwargs</span>.<span class="ruby-identifier">fetch</span> <span class="ruby-value">:protocol</span>, <span class="ruby-identifier">default_protocol</span>
159
+
160
+ <span class="ruby-comment"># TODO: Move this to #listen.</span>
161
+ <span class="ruby-keyword">case</span> <span class="ruby-ivar">@protocol</span>
162
+ <span class="ruby-keyword">when</span> <span class="ruby-value">:tcp</span>
163
+ <span class="ruby-ivar">@server</span> = <span class="ruby-constant">TCPServer</span>.<span class="ruby-identifier">new</span> <span class="ruby-ivar">@interface</span>, <span class="ruby-ivar">@port</span>
164
+ <span class="ruby-ivar">@server</span>.<span class="ruby-identifier">setsockopt</span> <span class="ruby-operator">::</span><span class="ruby-constant">Socket</span><span class="ruby-operator">::</span><span class="ruby-constant">SOL_SOCKET</span>, <span class="ruby-operator">::</span><span class="ruby-constant">Socket</span><span class="ruby-operator">::</span><span class="ruby-constant">SO_REUSEADDR</span>, [<span class="ruby-value">1</span>].<span class="ruby-identifier">pack</span>(<span class="ruby-string">&#39;i&#39;</span>)
165
+ <span class="ruby-keyword">when</span> <span class="ruby-value">:udp</span>
166
+ <span class="ruby-ivar">@server</span> = <span class="ruby-constant">Ionian</span><span class="ruby-operator">::</span><span class="ruby-constant">Socket</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">host</span><span class="ruby-operator">:</span> <span class="ruby-ivar">@interface</span>, <span class="ruby-identifier">port</span><span class="ruby-operator">:</span> <span class="ruby-ivar">@port</span>, <span class="ruby-identifier">protocol</span><span class="ruby-operator">:</span> <span class="ruby-value">:udp</span>
167
+ <span class="ruby-keyword">when</span> <span class="ruby-value">:unix</span>
168
+ <span class="ruby-ivar">@server</span> = <span class="ruby-constant">UNIXServer</span>.<span class="ruby-identifier">new</span> <span class="ruby-ivar">@interface</span>
169
+ <span class="ruby-keyword">end</span>
170
+ <span class="ruby-keyword">end</span></pre>
171
+ </div>
172
+
173
+ </div>
174
+
175
+
176
+
177
+
178
+ </div>
179
+
180
+
181
+ </section>
182
+
183
+ <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
184
+ <header>
185
+ <h3>Public Instance Methods</h3>
186
+ </header>
187
+
188
+
189
+ <div id="method-i-close" class="method-detail ">
190
+
191
+ <div class="method-heading">
192
+ <span class="method-name">close</span><span
193
+ class="method-args">()</span>
194
+
195
+ <span class="method-click-advice">click to toggle source</span>
196
+
197
+ </div>
198
+
199
+
200
+ <div class="method-description">
201
+
202
+ <p>Shutdown the server socket and stop listening for connections.</p>
203
+
204
+
205
+
206
+
207
+ <div class="method-source-code" id="close-source">
208
+ <pre><span class="ruby-comment"># File lib/ionian/server.rb, line 62</span>
209
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">close</span>
210
+ <span class="ruby-ivar">@server</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@server</span>
211
+ <span class="ruby-ivar">@accept_thread</span>.<span class="ruby-identifier">join</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@accept_thread</span>
212
+ <span class="ruby-ivar">@accept_thread</span> = <span class="ruby-keyword">nil</span>
213
+ <span class="ruby-keyword">end</span></pre>
214
+ </div>
215
+
216
+ </div>
217
+
218
+
219
+
220
+
221
+ </div>
222
+
223
+
224
+ <div id="method-i-listen" class="method-detail ">
225
+
226
+ <div class="method-heading">
227
+ <span class="method-name">listen</span><span
228
+ class="method-args">(&block)</span>
229
+
230
+ <span class="method-click-advice">click to toggle source</span>
231
+
232
+ </div>
233
+
234
+
235
+ <div class="method-description">
236
+
237
+ <p>Starts the socket server listening for connections. Blocks registered with
238
+ <a
239
+ href="Server.html#method-i-register_accept_listener">register_accept_listener</a>
240
+ will be run when a connection is accepted.</p>
241
+
242
+
243
+
244
+
245
+ <div class="method-source-code" id="listen-source">
246
+ <pre><span class="ruby-comment"># File lib/ionian/server.rb, line 40</span>
247
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">listen</span> <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
248
+ <span class="ruby-identifier">register_accept_listener</span> <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">block_given?</span>
249
+
250
+ <span class="ruby-ivar">@accept_thread</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span>
251
+ <span class="ruby-comment"># Package in an Ionian::Socket</span>
252
+ <span class="ruby-keyword">begin</span>
253
+ <span class="ruby-identifier">client</span> = <span class="ruby-constant">Ionian</span><span class="ruby-operator">::</span><span class="ruby-constant">Socket</span>.<span class="ruby-identifier">new</span> <span class="ruby-ivar">@server</span>.<span class="ruby-identifier">accept</span>
254
+
255
+ <span class="ruby-ivar">@accept_listeners</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">listener</span><span class="ruby-operator">|</span>
256
+ <span class="ruby-identifier">listener</span>.<span class="ruby-identifier">call</span> <span class="ruby-identifier">client</span>
257
+ <span class="ruby-keyword">end</span>
258
+ <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EBADF</span>
259
+ <span class="ruby-comment"># This ignores the connection if the client closed it before it</span>
260
+ <span class="ruby-comment"># could be accepted.</span>
261
+ <span class="ruby-keyword">rescue</span> <span class="ruby-constant">IOError</span>
262
+ <span class="ruby-comment"># This ignores the connection if the client closed it before it</span>
263
+ <span class="ruby-comment"># could be accepted.</span>
264
+ <span class="ruby-keyword">end</span>
265
+ <span class="ruby-keyword">end</span>
266
+ <span class="ruby-keyword">end</span></pre>
267
+ </div>
268
+
269
+ </div>
270
+
271
+
272
+
273
+
274
+ </div>
275
+
276
+
277
+ <div id="method-i-on_accept" class="method-detail method-alias">
278
+
279
+ <div class="method-heading">
280
+ <span class="method-name">on_accept</span><span
281
+ class="method-args">(&block)</span>
282
+
283
+ </div>
284
+
285
+
286
+ <div class="method-description">
287
+
288
+
289
+
290
+
291
+
292
+
293
+ </div>
294
+
295
+
296
+
297
+
298
+ <div class="aliases">
299
+ Alias for: <a href="Server.html#method-i-register_accept_listener">register_accept_listener</a>
300
+ </div>
301
+
302
+ </div>
303
+
304
+
305
+ <div id="method-i-register_accept_listener" class="method-detail ">
306
+
307
+ <div class="method-heading">
308
+ <span class="method-name">register_accept_listener</span><span
309
+ class="method-args">(&block)</span>
310
+
311
+ <span class="method-click-advice">click to toggle source</span>
312
+
313
+ </div>
314
+
315
+
316
+ <div class="method-description">
317
+
318
+ <p>Register a block to be run when server accepts a client connection. The
319
+ connected client is passed to the block as an Ionain::Client.</p>
320
+
321
+
322
+
323
+
324
+ <div class="method-source-code" id="register_accept_listener-source">
325
+ <pre><span class="ruby-comment"># File lib/ionian/server.rb, line 70</span>
326
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">register_accept_listener</span> <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
327
+ <span class="ruby-ivar">@accept_listeners</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">block</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@accept_listeners</span>.<span class="ruby-identifier">include?</span> <span class="ruby-identifier">block</span>
328
+ <span class="ruby-identifier">block</span>
329
+ <span class="ruby-keyword">end</span></pre>
330
+ </div>
331
+
332
+ </div>
333
+
334
+
335
+ <div class="aliases">
336
+ Also aliased as: <a href="Server.html#method-i-on_accept">on_accept</a>
337
+ </div>
338
+
339
+
340
+
341
+ </div>
342
+
343
+
344
+ <div id="method-i-unregister_accept_listener" class="method-detail ">
345
+
346
+ <div class="method-heading">
347
+ <span class="method-name">unregister_accept_listener</span><span
348
+ class="method-args">(proc)</span>
349
+
350
+ <span class="method-click-advice">click to toggle source</span>
351
+
352
+ </div>
353
+
354
+
355
+ <div class="method-description">
356
+
357
+ <p>Unregisters a socket accept notifier block.</p>
358
+
359
+
360
+
361
+
362
+ <div class="method-source-code" id="unregister_accept_listener-source">
363
+ <pre><span class="ruby-comment"># File lib/ionian/server.rb, line 78</span>
364
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">unregister_accept_listener</span> <span class="ruby-identifier">proc</span>
365
+ <span class="ruby-ivar">@accept_listeners</span>.<span class="ruby-identifier">delete_if</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">o</span><span class="ruby-operator">|</span> <span class="ruby-identifier">o</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">proc</span>}
366
+ <span class="ruby-identifier">proc</span>
367
+ <span class="ruby-keyword">end</span></pre>
368
+ </div>
369
+
370
+ </div>
371
+
372
+
373
+
374
+
375
+ </div>
376
+
377
+
378
+ </section>
379
+
380
+ </section>
381
+ </main>
382
+
383
+
384
+ <footer id="validator-badges" role="contentinfo">
385
+ <p><a href="http://validator.w3.org/check/referer">Validate</a>
386
+ <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.0.
387
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
388
+ </footer>
389
+