rawjsonrpc 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +2 -4
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/doc/rdoc/README_rdoc.html +238 -0
- data/doc/rdoc/RawJsonRpc/ClientSock.html +244 -0
- data/doc/rdoc/RawJsonRpc/RawClientJsonRpc.html +387 -0
- data/doc/rdoc/RawJsonRpc/RawServerJsonRpc.html +310 -0
- data/doc/rdoc/RawJsonRpc/ServerSocket.html +290 -0
- data/doc/rdoc/RawJsonRpc/TCPServer.html +166 -0
- data/doc/rdoc/RawJsonRpc.html +174 -0
- data/doc/rdoc/RpcError.html +158 -0
- data/doc/rdoc/created.rid +6 -0
- data/doc/rdoc/images/brick.png +0 -0
- data/doc/rdoc/images/brick_link.png +0 -0
- data/doc/rdoc/images/bug.png +0 -0
- data/doc/rdoc/images/bullet_black.png +0 -0
- data/doc/rdoc/images/bullet_toggle_minus.png +0 -0
- data/doc/rdoc/images/bullet_toggle_plus.png +0 -0
- data/doc/rdoc/images/date.png +0 -0
- data/doc/rdoc/images/find.png +0 -0
- data/doc/rdoc/images/loadingAnimation.gif +0 -0
- data/doc/rdoc/images/macFFBgHack.png +0 -0
- data/doc/rdoc/images/package.png +0 -0
- data/doc/rdoc/images/page_green.png +0 -0
- data/doc/rdoc/images/page_white_text.png +0 -0
- data/doc/rdoc/images/page_white_width.png +0 -0
- data/doc/rdoc/images/plugin.png +0 -0
- data/doc/rdoc/images/ruby.png +0 -0
- data/doc/rdoc/images/tag_green.png +0 -0
- data/doc/rdoc/images/wrench.png +0 -0
- data/doc/rdoc/images/wrench_orange.png +0 -0
- data/doc/rdoc/images/zoom.png +0 -0
- data/doc/rdoc/index.html +92 -0
- data/doc/rdoc/js/darkfish.js +116 -0
- data/doc/rdoc/js/jquery.js +32 -0
- data/doc/rdoc/js/quicksearch.js +114 -0
- data/doc/rdoc/js/thickbox-compressed.js +10 -0
- data/doc/rdoc/lib/rawjsonrpc/client_rb.html +63 -0
- data/doc/rdoc/lib/rawjsonrpc/error_rb.html +59 -0
- data/doc/rdoc/lib/rawjsonrpc/server_rb.html +67 -0
- data/doc/rdoc/lib/rawjsonrpc_rb.html +61 -0
- data/doc/rdoc/rdoc.css +763 -0
- data/rawjsonrpc.gemspec +95 -0
- metadata +48 -8
@@ -0,0 +1,310 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
|
7
|
+
|
8
|
+
<title>Module: RawJsonRpc::RawServerJsonRpc</title>
|
9
|
+
|
10
|
+
<link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
|
11
|
+
|
12
|
+
<script src="../js/jquery.js" type="text/javascript" charset="utf-8"></script>
|
13
|
+
<script src="../js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
|
14
|
+
<script src="../js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
|
15
|
+
<script src="../js/darkfish.js" type="text/javascript" charset="utf-8"></script>
|
16
|
+
|
17
|
+
</head>
|
18
|
+
<body id="top" class="module">
|
19
|
+
|
20
|
+
<div id="metadata">
|
21
|
+
<div id="home-metadata">
|
22
|
+
<div id="home-section" class="section">
|
23
|
+
<h3 class="section-header">
|
24
|
+
<a href="../index.html">Home</a>
|
25
|
+
<a href="../index.html#classes">Classes</a>
|
26
|
+
<a href="../index.html#methods">Methods</a>
|
27
|
+
</h3>
|
28
|
+
</div>
|
29
|
+
</div>
|
30
|
+
|
31
|
+
<div id="file-metadata">
|
32
|
+
<div id="file-list-section" class="section">
|
33
|
+
<h3 class="section-header">In Files</h3>
|
34
|
+
<div class="section-body">
|
35
|
+
<ul>
|
36
|
+
|
37
|
+
<li><a href="../lib/rawjsonrpc/server_rb.html?TB_iframe=true&height=550&width=785"
|
38
|
+
class="thickbox" title="lib/rawjsonrpc/server.rb">lib/rawjsonrpc/server.rb</a></li>
|
39
|
+
|
40
|
+
</ul>
|
41
|
+
</div>
|
42
|
+
</div>
|
43
|
+
|
44
|
+
|
45
|
+
</div>
|
46
|
+
|
47
|
+
<div id="class-metadata">
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
<!-- Method Quickref -->
|
56
|
+
<div id="method-list-section" class="section">
|
57
|
+
<h3 class="section-header">Methods</h3>
|
58
|
+
<ul class="link-list">
|
59
|
+
|
60
|
+
<li><a href="#method-i-add_block">#add_block</a></li>
|
61
|
+
|
62
|
+
<li><a href="#method-i-add_method">#add_method</a></li>
|
63
|
+
|
64
|
+
<li><a href="#method-i-execute">#execute</a></li>
|
65
|
+
|
66
|
+
</ul>
|
67
|
+
</div>
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
</div>
|
72
|
+
|
73
|
+
<div id="project-metadata">
|
74
|
+
|
75
|
+
|
76
|
+
<div id="fileindex-section" class="section project-section">
|
77
|
+
<h3 class="section-header">Files</h3>
|
78
|
+
<ul>
|
79
|
+
|
80
|
+
<li class="file"><a href="../README_rdoc.html">README.rdoc</a></li>
|
81
|
+
|
82
|
+
</ul>
|
83
|
+
</div>
|
84
|
+
|
85
|
+
|
86
|
+
<div id="classindex-section" class="section project-section">
|
87
|
+
<h3 class="section-header">Class/Module Index
|
88
|
+
<span class="search-toggle"><img src="../images/find.png"
|
89
|
+
height="16" width="16" alt="[+]"
|
90
|
+
title="show/hide quicksearch" /></span></h3>
|
91
|
+
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
|
92
|
+
<fieldset>
|
93
|
+
<legend>Quicksearch</legend>
|
94
|
+
<input type="text" name="quicksearch" value=""
|
95
|
+
class="quicksearch-field" />
|
96
|
+
</fieldset>
|
97
|
+
</form>
|
98
|
+
|
99
|
+
<ul class="link-list">
|
100
|
+
|
101
|
+
<li><a href="../RawJsonRpc.html">RawJsonRpc</a></li>
|
102
|
+
|
103
|
+
<li><a href="../RawJsonRpc/ClientSock.html">RawJsonRpc::ClientSock</a></li>
|
104
|
+
|
105
|
+
<li><a href="../RawJsonRpc/RawClientJsonRpc.html">RawJsonRpc::RawClientJsonRpc</a></li>
|
106
|
+
|
107
|
+
<li><a href="../RawJsonRpc/RawServerJsonRpc.html">RawJsonRpc::RawServerJsonRpc</a></li>
|
108
|
+
|
109
|
+
<li><a href="../RawJsonRpc/ServerSocket.html">RawJsonRpc::ServerSocket</a></li>
|
110
|
+
|
111
|
+
<li><a href="../RawJsonRpc/TCPServer.html">RawJsonRpc::TCPServer</a></li>
|
112
|
+
|
113
|
+
<li><a href="../RpcError.html">RpcError</a></li>
|
114
|
+
|
115
|
+
</ul>
|
116
|
+
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
|
117
|
+
</div>
|
118
|
+
|
119
|
+
|
120
|
+
</div>
|
121
|
+
</div>
|
122
|
+
|
123
|
+
<div id="documentation">
|
124
|
+
<h1 class="module">RawJsonRpc::RawServerJsonRpc</h1>
|
125
|
+
|
126
|
+
<div id="description" class="description">
|
127
|
+
|
128
|
+
<p>Implements the basic server functions When implementing a new server type
|
129
|
+
you must only give a jsonstring to the execute function.</p>
|
130
|
+
|
131
|
+
<h1>Example</h1>
|
132
|
+
|
133
|
+
<p>Add Functions</p>
|
134
|
+
|
135
|
+
<pre>server.add_method("run", methode(:test)) #adds methode test as "run"
|
136
|
+
server.add_block("attack"){ |target, dir, times|
|
137
|
+
#stuff
|
138
|
+
}</pre>
|
139
|
+
|
140
|
+
</div><!-- description -->
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
<div id="5Buntitled-5D" class="documentation-section">
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
<!-- Methods -->
|
155
|
+
|
156
|
+
<div id="public-instance-method-details" class="method-section section">
|
157
|
+
<h3 class="section-header">Public Instance Methods</h3>
|
158
|
+
|
159
|
+
|
160
|
+
<div id="add_block-method" class="method-detail ">
|
161
|
+
<a name="method-i-add_block"></a>
|
162
|
+
|
163
|
+
|
164
|
+
<div class="method-heading">
|
165
|
+
<span class="method-name">add_block</span><span
|
166
|
+
class="method-args">(name, &block)</span>
|
167
|
+
<span class="method-click-advice">click to toggle source</span>
|
168
|
+
</div>
|
169
|
+
|
170
|
+
|
171
|
+
<div class="method-description">
|
172
|
+
|
173
|
+
<p>Adds blocks that get executed Arguments can not checkt because they are
|
174
|
+
procs no lambdas if you can provied a hack plz contribute.</p>
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
<div class="method-source-code" id="add_block-source">
|
179
|
+
<pre>
|
180
|
+
<span class="ruby-comment"># File lib/rawjsonrpc/server.rb, line 36</span>
|
181
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">add_block</span>(<span class="ruby-identifier">name</span>, &<span class="ruby-identifier">block</span>)
|
182
|
+
<span class="ruby-ivar">@rawjsonrpc_blocks</span> <span class="ruby-operator">||=</span> {}
|
183
|
+
<span class="ruby-ivar">@rawjsonrpc_funcs</span> <span class="ruby-operator">||=</span> {}
|
184
|
+
<span class="ruby-ivar">@rawjsonrpc_blocks</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">block</span>
|
185
|
+
<span class="ruby-keyword">end</span></pre>
|
186
|
+
</div><!-- add_block-source -->
|
187
|
+
|
188
|
+
</div>
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
</div><!-- add_block-method -->
|
194
|
+
|
195
|
+
|
196
|
+
<div id="add_method-method" class="method-detail ">
|
197
|
+
<a name="method-i-add_method"></a>
|
198
|
+
|
199
|
+
|
200
|
+
<div class="method-heading">
|
201
|
+
<span class="method-name">add_method</span><span
|
202
|
+
class="method-args">(name, func)</span>
|
203
|
+
<span class="method-click-advice">click to toggle source</span>
|
204
|
+
</div>
|
205
|
+
|
206
|
+
|
207
|
+
<div class="method-description">
|
208
|
+
|
209
|
+
<p>Adds methode to be executed</p>
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
<div class="method-source-code" id="add_method-source">
|
214
|
+
<pre>
|
215
|
+
<span class="ruby-comment"># File lib/rawjsonrpc/server.rb, line 28</span>
|
216
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">add_method</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">func</span>)
|
217
|
+
<span class="ruby-ivar">@rawjsonrpc_funcs</span> <span class="ruby-operator">||=</span> {}
|
218
|
+
<span class="ruby-ivar">@rawjsonrpc_blocks</span> <span class="ruby-operator">||=</span> {}
|
219
|
+
<span class="ruby-ivar">@rawjsonrpc_funcs</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">func</span>
|
220
|
+
<span class="ruby-keyword">end</span></pre>
|
221
|
+
</div><!-- add_method-source -->
|
222
|
+
|
223
|
+
</div>
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
</div><!-- add_method-method -->
|
229
|
+
|
230
|
+
|
231
|
+
</div><!-- public-instance-method-details -->
|
232
|
+
|
233
|
+
<div id="protected-instance-method-details" class="method-section section">
|
234
|
+
<h3 class="section-header">Protected Instance Methods</h3>
|
235
|
+
|
236
|
+
|
237
|
+
<div id="execute-method" class="method-detail ">
|
238
|
+
<a name="method-i-execute"></a>
|
239
|
+
|
240
|
+
|
241
|
+
<div class="method-heading">
|
242
|
+
<span class="method-name">execute</span><span
|
243
|
+
class="method-args">(input)</span>
|
244
|
+
<span class="method-click-advice">click to toggle source</span>
|
245
|
+
</div>
|
246
|
+
|
247
|
+
|
248
|
+
<div class="method-description">
|
249
|
+
|
250
|
+
<p>Handels json string input and calls the methode and returns a return string
|
251
|
+
or nil if its a notification.</p>
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
<div class="method-source-code" id="execute-source">
|
256
|
+
<pre>
|
257
|
+
<span class="ruby-comment"># File lib/rawjsonrpc/server.rb, line 44</span>
|
258
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">execute</span>(<span class="ruby-identifier">input</span>)
|
259
|
+
<span class="ruby-keyword">begin</span>
|
260
|
+
<span class="ruby-identifier">request_data</span> = <span class="ruby-constant">JSON</span>.<span class="ruby-identifier">load</span>(<span class="ruby-identifier">input</span>)
|
261
|
+
<span class="ruby-ivar">@rawjsonrpc_noti</span> = <span class="ruby-keyword">if</span> <span class="ruby-identifier">request_data</span>[<span class="ruby-string">"id"</span>] <span class="ruby-operator">==</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">then</span> <span class="ruby-keyword">true</span>
|
262
|
+
<span class="ruby-keyword">else</span> <span class="ruby-keyword">false</span>
|
263
|
+
<span class="ruby-keyword">end</span>
|
264
|
+
<span class="ruby-ivar">@rawjsonrpc_id</span> = <span class="ruby-identifier">request_data</span>[<span class="ruby-string">"id"</span>]
|
265
|
+
<span class="ruby-keyword">if</span> <span class="ruby-ivar">@rawjsonrpc_funcs</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">request_data</span>[<span class="ruby-string">"method"</span>])
|
266
|
+
<span class="ruby-identifier">ret</span> = <span class="ruby-ivar">@rawjsonrpc_funcs</span>[<span class="ruby-identifier">request_data</span>[<span class="ruby-string">"method"</span>]].<span class="ruby-identifier">call</span>(*<span class="ruby-identifier">request_data</span>[<span class="ruby-string">"params"</span>])
|
267
|
+
<span class="ruby-keyword">elsif</span> <span class="ruby-ivar">@rawjsonrpc_blocks</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">request_data</span>[<span class="ruby-string">"method"</span>])
|
268
|
+
<span class="ruby-identifier">ret</span> = <span class="ruby-ivar">@rawjsonrpc_blocks</span>[<span class="ruby-identifier">request_data</span>[<span class="ruby-string">"method"</span>]].<span class="ruby-identifier">call</span>(*<span class="ruby-identifier">request_data</span>[<span class="ruby-string">"params"</span>])
|
269
|
+
<span class="ruby-keyword">else</span>
|
270
|
+
<span class="ruby-ivar">@rawjsonrpc_back</span> = <span class="ruby-identifier">request_data</span>
|
271
|
+
<span class="ruby-identifier">raise</span>(<span class="ruby-string">"No Methode"</span>)
|
272
|
+
<span class="ruby-keyword">end</span>
|
273
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">request_data</span>[<span class="ruby-string">"id"</span>] <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span>
|
274
|
+
<span class="ruby-identifier">response_data</span> = {<span class="ruby-string">"result"</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">ret</span>, <span class="ruby-string">"error"</span> =<span class="ruby-operator">></span> <span class="ruby-keyword">nil</span>, <span class="ruby-string">"id"</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">request_data</span>[<span class="ruby-string">"id"</span>]}
|
275
|
+
.<span class="ruby-identifier">to_json</span>
|
276
|
+
<span class="ruby-keyword">else</span> <span class="ruby-keyword">nil</span>
|
277
|
+
<span class="ruby-keyword">end</span>
|
278
|
+
<span class="ruby-keyword">rescue</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">ex</span>
|
279
|
+
<span class="ruby-keyword">unless</span> <span class="ruby-ivar">@rawjsonrpc_noti</span>
|
280
|
+
<span class="ruby-identifier">response</span> = {<span class="ruby-string">"result"</span> =<span class="ruby-operator">></span> <span class="ruby-keyword">nil</span>, <span class="ruby-string">"error"</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">ex</span>.<span class="ruby-identifier">message</span>,
|
281
|
+
<span class="ruby-string">"id"</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@rawjsonrpc_id</span>}.<span class="ruby-identifier">to_json</span>
|
282
|
+
<span class="ruby-keyword">end</span>
|
283
|
+
<span class="ruby-keyword">end</span>
|
284
|
+
<span class="ruby-keyword">end</span></pre>
|
285
|
+
</div><!-- execute-source -->
|
286
|
+
|
287
|
+
</div>
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
|
292
|
+
</div><!-- execute-method -->
|
293
|
+
|
294
|
+
|
295
|
+
</div><!-- protected-instance-method-details -->
|
296
|
+
|
297
|
+
</div><!-- 5Buntitled-5D -->
|
298
|
+
|
299
|
+
|
300
|
+
</div><!-- documentation -->
|
301
|
+
|
302
|
+
<div id="validator-badges">
|
303
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
304
|
+
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
305
|
+
Rdoc Generator</a> 2</small>.</p>
|
306
|
+
</div>
|
307
|
+
|
308
|
+
</body>
|
309
|
+
</html>
|
310
|
+
|
@@ -0,0 +1,290 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
|
7
|
+
|
8
|
+
<title>Class: RawJsonRpc::ServerSocket</title>
|
9
|
+
|
10
|
+
<link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
|
11
|
+
|
12
|
+
<script src="../js/jquery.js" type="text/javascript" charset="utf-8"></script>
|
13
|
+
<script src="../js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
|
14
|
+
<script src="../js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
|
15
|
+
<script src="../js/darkfish.js" type="text/javascript" charset="utf-8"></script>
|
16
|
+
|
17
|
+
</head>
|
18
|
+
<body id="top" class="class">
|
19
|
+
|
20
|
+
<div id="metadata">
|
21
|
+
<div id="home-metadata">
|
22
|
+
<div id="home-section" class="section">
|
23
|
+
<h3 class="section-header">
|
24
|
+
<a href="../index.html">Home</a>
|
25
|
+
<a href="../index.html#classes">Classes</a>
|
26
|
+
<a href="../index.html#methods">Methods</a>
|
27
|
+
</h3>
|
28
|
+
</div>
|
29
|
+
</div>
|
30
|
+
|
31
|
+
<div id="file-metadata">
|
32
|
+
<div id="file-list-section" class="section">
|
33
|
+
<h3 class="section-header">In Files</h3>
|
34
|
+
<div class="section-body">
|
35
|
+
<ul>
|
36
|
+
|
37
|
+
<li><a href="../lib/rawjsonrpc/server_rb.html?TB_iframe=true&height=550&width=785"
|
38
|
+
class="thickbox" title="lib/rawjsonrpc/server.rb">lib/rawjsonrpc/server.rb</a></li>
|
39
|
+
|
40
|
+
</ul>
|
41
|
+
</div>
|
42
|
+
</div>
|
43
|
+
|
44
|
+
|
45
|
+
</div>
|
46
|
+
|
47
|
+
<div id="class-metadata">
|
48
|
+
|
49
|
+
<!-- Parent Class -->
|
50
|
+
<div id="parent-class-section" class="section">
|
51
|
+
<h3 class="section-header">Parent</h3>
|
52
|
+
|
53
|
+
<p class="link">Object</p>
|
54
|
+
|
55
|
+
</div>
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
<!-- Method Quickref -->
|
64
|
+
<div id="method-list-section" class="section">
|
65
|
+
<h3 class="section-header">Methods</h3>
|
66
|
+
<ul class="link-list">
|
67
|
+
|
68
|
+
<li><a href="#method-c-new">::new</a></li>
|
69
|
+
|
70
|
+
<li><a href="#method-i-server">#server</a></li>
|
71
|
+
|
72
|
+
</ul>
|
73
|
+
</div>
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
<!-- Included Modules -->
|
78
|
+
<div id="includes-section" class="section">
|
79
|
+
<h3 class="section-header">Included Modules</h3>
|
80
|
+
<ul class="link-list">
|
81
|
+
|
82
|
+
|
83
|
+
<li><a class="include" href="RawServerJsonRpc.html">RawJsonRpc::RawServerJsonRpc</a></li>
|
84
|
+
|
85
|
+
|
86
|
+
</ul>
|
87
|
+
</div>
|
88
|
+
|
89
|
+
</div>
|
90
|
+
|
91
|
+
<div id="project-metadata">
|
92
|
+
|
93
|
+
|
94
|
+
<div id="fileindex-section" class="section project-section">
|
95
|
+
<h3 class="section-header">Files</h3>
|
96
|
+
<ul>
|
97
|
+
|
98
|
+
<li class="file"><a href="../README_rdoc.html">README.rdoc</a></li>
|
99
|
+
|
100
|
+
</ul>
|
101
|
+
</div>
|
102
|
+
|
103
|
+
|
104
|
+
<div id="classindex-section" class="section project-section">
|
105
|
+
<h3 class="section-header">Class/Module Index
|
106
|
+
<span class="search-toggle"><img src="../images/find.png"
|
107
|
+
height="16" width="16" alt="[+]"
|
108
|
+
title="show/hide quicksearch" /></span></h3>
|
109
|
+
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
|
110
|
+
<fieldset>
|
111
|
+
<legend>Quicksearch</legend>
|
112
|
+
<input type="text" name="quicksearch" value=""
|
113
|
+
class="quicksearch-field" />
|
114
|
+
</fieldset>
|
115
|
+
</form>
|
116
|
+
|
117
|
+
<ul class="link-list">
|
118
|
+
|
119
|
+
<li><a href="../RawJsonRpc.html">RawJsonRpc</a></li>
|
120
|
+
|
121
|
+
<li><a href="../RawJsonRpc/ClientSock.html">RawJsonRpc::ClientSock</a></li>
|
122
|
+
|
123
|
+
<li><a href="../RawJsonRpc/RawClientJsonRpc.html">RawJsonRpc::RawClientJsonRpc</a></li>
|
124
|
+
|
125
|
+
<li><a href="../RawJsonRpc/RawServerJsonRpc.html">RawJsonRpc::RawServerJsonRpc</a></li>
|
126
|
+
|
127
|
+
<li><a href="../RawJsonRpc/ServerSocket.html">RawJsonRpc::ServerSocket</a></li>
|
128
|
+
|
129
|
+
<li><a href="../RawJsonRpc/TCPServer.html">RawJsonRpc::TCPServer</a></li>
|
130
|
+
|
131
|
+
<li><a href="../RpcError.html">RpcError</a></li>
|
132
|
+
|
133
|
+
</ul>
|
134
|
+
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
|
135
|
+
</div>
|
136
|
+
|
137
|
+
|
138
|
+
</div>
|
139
|
+
</div>
|
140
|
+
|
141
|
+
<div id="documentation">
|
142
|
+
<h1 class="class">RawJsonRpc::ServerSocket</h1>
|
143
|
+
|
144
|
+
<div id="description" class="description">
|
145
|
+
|
146
|
+
<p>Implements RawServerJsonRpcBase for a <a
|
147
|
+
href="TCPServer.html">TCPServer</a>, that can only handle one client at
|
148
|
+
once.</p>
|
149
|
+
|
150
|
+
</div><!-- description -->
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
<div id="5Buntitled-5D" class="documentation-section">
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
<!-- Methods -->
|
165
|
+
|
166
|
+
<div id="public-class-method-details" class="method-section section">
|
167
|
+
<h3 class="section-header">Public Class Methods</h3>
|
168
|
+
|
169
|
+
|
170
|
+
<div id="new-method" class="method-detail ">
|
171
|
+
<a name="method-c-new"></a>
|
172
|
+
|
173
|
+
|
174
|
+
<div class="method-heading">
|
175
|
+
<span class="method-name">new</span><span
|
176
|
+
class="method-args">(port, logger=nil)</span>
|
177
|
+
<span class="method-click-advice">click to toggle source</span>
|
178
|
+
</div>
|
179
|
+
|
180
|
+
|
181
|
+
<div class="method-description">
|
182
|
+
|
183
|
+
<p>sets the port for serving. Optimal you can add a logger object to log
|
184
|
+
server activities.</p>
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
<div class="method-source-code" id="new-source">
|
189
|
+
<pre>
|
190
|
+
<span class="ruby-comment"># File lib/rawjsonrpc/server.rb, line 78</span>
|
191
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">port</span>, <span class="ruby-identifier">logger</span>=<span class="ruby-keyword">nil</span>)
|
192
|
+
<span class="ruby-ivar">@port</span> = <span class="ruby-identifier">port</span>
|
193
|
+
<span class="ruby-ivar">@log</span> = <span class="ruby-identifier">logger</span>
|
194
|
+
<span class="ruby-keyword">end</span></pre>
|
195
|
+
</div><!-- new-source -->
|
196
|
+
|
197
|
+
</div>
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
</div><!-- new-method -->
|
203
|
+
|
204
|
+
|
205
|
+
</div><!-- public-class-method-details -->
|
206
|
+
|
207
|
+
<div id="public-instance-method-details" class="method-section section">
|
208
|
+
<h3 class="section-header">Public Instance Methods</h3>
|
209
|
+
|
210
|
+
|
211
|
+
<div id="server-method" class="method-detail ">
|
212
|
+
<a name="method-i-server"></a>
|
213
|
+
|
214
|
+
|
215
|
+
<div class="method-heading">
|
216
|
+
<span class="method-name">server</span><span
|
217
|
+
class="method-args">()</span>
|
218
|
+
<span class="method-click-advice">click to toggle source</span>
|
219
|
+
</div>
|
220
|
+
|
221
|
+
|
222
|
+
<div class="method-description">
|
223
|
+
|
224
|
+
<p>Starts the servering the methods for clients</p>
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
<div class="method-source-code" id="server-source">
|
229
|
+
<pre>
|
230
|
+
<span class="ruby-comment"># File lib/rawjsonrpc/server.rb, line 91</span>
|
231
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">server</span>
|
232
|
+
<span class="ruby-identifier">check</span> <span class="ruby-identifier">log</span>.<span class="ruby-identifier">level</span>, <span class="ruby-string">"start serving data at "</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@port</span>.<span class="ruby-identifier">to_s</span>
|
233
|
+
<span class="ruby-identifier">server</span> = <span class="ruby-constant">TCPServer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@port</span>)
|
234
|
+
<span class="ruby-identifier">client</span> = <span class="ruby-identifier">server</span>.<span class="ruby-identifier">accept</span>
|
235
|
+
<span class="ruby-identifier">loop</span> <span class="ruby-keyword">do</span>
|
236
|
+
<span class="ruby-keyword">begin</span>
|
237
|
+
<span class="ruby-identifier">data</span> = <span class="ruby-identifier">client</span>.<span class="ruby-identifier">gets</span>
|
238
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">data</span> <span class="ruby-operator">==</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">data</span> <span class="ruby-operator">==</span> <span class="ruby-string">"END\n"</span>
|
239
|
+
<span class="ruby-identifier">check</span> <span class="ruby-ivar">@log</span>.<span class="ruby-identifier">info</span>, <span class="ruby-string">"client closed connection"</span>
|
240
|
+
<span class="ruby-identifier">client</span>.<span class="ruby-identifier">close</span>
|
241
|
+
<span class="ruby-identifier">client</span> = <span class="ruby-identifier">server</span>.<span class="ruby-identifier">accept</span>
|
242
|
+
<span class="ruby-keyword">next</span>
|
243
|
+
<span class="ruby-keyword">end</span>
|
244
|
+
<span class="ruby-identifier">check</span> <span class="ruby-ivar">@log</span>.<span class="ruby-identifier">info</span>, <span class="ruby-string">"recived from client "</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">data</span>
|
245
|
+
<span class="ruby-identifier">data</span> = <span class="ruby-identifier">execute</span>(<span class="ruby-identifier">data</span>)
|
246
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">data</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span>
|
247
|
+
<span class="ruby-identifier">check</span> <span class="ruby-ivar">@log</span>.<span class="ruby-identifier">info</span>, <span class="ruby-string">"send to client "</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">data</span>
|
248
|
+
<span class="ruby-identifier">client</span>.<span class="ruby-identifier">puts</span>(<span class="ruby-identifier">data</span>)
|
249
|
+
<span class="ruby-keyword">end</span>
|
250
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">SocketError</span>
|
251
|
+
<span class="ruby-identifier">check</span> <span class="ruby-ivar">@log</span>.<span class="ruby-identifier">info</span>, <span class="ruby-string">"client closed connection"</span>
|
252
|
+
<span class="ruby-identifier">client</span>.<span class="ruby-identifier">close</span>
|
253
|
+
<span class="ruby-identifier">client</span> = <span class="ruby-identifier">server</span>.<span class="ruby-identifier">accept</span>
|
254
|
+
<span class="ruby-comment"># Exception from get killed</span>
|
255
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EPIPE</span>
|
256
|
+
<span class="ruby-identifier">check</span> <span class="ruby-ivar">@log</span>.<span class="ruby-identifier">info</span>, <span class="ruby-string">"server get killed"</span>
|
257
|
+
<span class="ruby-identifier">exit</span>
|
258
|
+
<span class="ruby-keyword">rescue</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">ex</span>
|
259
|
+
<span class="ruby-identifier">check</span> <span class="ruby-ivar">@log</span>.<span class="ruby-identifier">fatal</span>, <span class="ruby-string">"server get killed from: "</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">ex</span>.<span class="ruby-identifier">message</span>
|
260
|
+
<span class="ruby-identifier">client</span>.<span class="ruby-identifier">close</span>
|
261
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-identifier">ex</span>
|
262
|
+
<span class="ruby-keyword">end</span>
|
263
|
+
<span class="ruby-keyword">end</span>
|
264
|
+
<span class="ruby-keyword">end</span></pre>
|
265
|
+
</div><!-- server-source -->
|
266
|
+
|
267
|
+
</div>
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
</div><!-- server-method -->
|
273
|
+
|
274
|
+
|
275
|
+
</div><!-- public-instance-method-details -->
|
276
|
+
|
277
|
+
</div><!-- 5Buntitled-5D -->
|
278
|
+
|
279
|
+
|
280
|
+
</div><!-- documentation -->
|
281
|
+
|
282
|
+
<div id="validator-badges">
|
283
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
284
|
+
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
285
|
+
Rdoc Generator</a> 2</small>.</p>
|
286
|
+
</div>
|
287
|
+
|
288
|
+
</body>
|
289
|
+
</html>
|
290
|
+
|