|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric7.Toolbox.SingleApplication</title> |
|
4 <meta charset="UTF-8"> |
|
5 <style> |
|
6 body { |
|
7 background: #EDECE6; |
|
8 margin: 0em 1em 10em 1em; |
|
9 color: black; |
|
10 } |
|
11 |
|
12 h1 { color: white; background: #85774A; } |
|
13 h2 { color: white; background: #85774A; } |
|
14 h3 { color: white; background: #9D936E; } |
|
15 h4 { color: white; background: #9D936E; } |
|
16 |
|
17 a { color: #BA6D36; } |
|
18 |
|
19 </style> |
|
20 </head> |
|
21 <body> |
|
22 <a NAME="top" ID="top"></a> |
|
23 <h1>eric7.Toolbox.SingleApplication</h1> |
|
24 |
|
25 <p> |
|
26 Module implementing the single application server and client. |
|
27 </p> |
|
28 <h3>Global Attributes</h3> |
|
29 |
|
30 <table> |
|
31 <tr><td>None</td></tr> |
|
32 </table> |
|
33 <h3>Classes</h3> |
|
34 |
|
35 <table> |
|
36 |
|
37 <tr> |
|
38 <td><a href="#SingleApplicationClient">SingleApplicationClient</a></td> |
|
39 <td>Class implementing the single application client base class.</td> |
|
40 </tr> |
|
41 <tr> |
|
42 <td><a href="#SingleApplicationServer">SingleApplicationServer</a></td> |
|
43 <td>Class implementing the single application server base class.</td> |
|
44 </tr> |
|
45 </table> |
|
46 <h3>Functions</h3> |
|
47 |
|
48 <table> |
|
49 <tr><td>None</td></tr> |
|
50 </table> |
|
51 <hr /> |
|
52 <hr /> |
|
53 <a NAME="SingleApplicationClient" ID="SingleApplicationClient"></a> |
|
54 <h2>SingleApplicationClient</h2> |
|
55 |
|
56 <p> |
|
57 Class implementing the single application client base class. |
|
58 </p> |
|
59 <h3>Derived from</h3> |
|
60 None |
|
61 <h3>Class Attributes</h3> |
|
62 |
|
63 <table> |
|
64 <tr><td>None</td></tr> |
|
65 </table> |
|
66 <h3>Class Methods</h3> |
|
67 |
|
68 <table> |
|
69 <tr><td>None</td></tr> |
|
70 </table> |
|
71 <h3>Methods</h3> |
|
72 |
|
73 <table> |
|
74 |
|
75 <tr> |
|
76 <td><a href="#SingleApplicationClient.__init__">SingleApplicationClient</a></td> |
|
77 <td>Constructor</td> |
|
78 </tr> |
|
79 <tr> |
|
80 <td><a href="#SingleApplicationClient.connect">connect</a></td> |
|
81 <td>Public method to connect the single application client to its server.</td> |
|
82 </tr> |
|
83 <tr> |
|
84 <td><a href="#SingleApplicationClient.disconnect">disconnect</a></td> |
|
85 <td>Public method to disconnect from the Single Appliocation server.</td> |
|
86 </tr> |
|
87 <tr> |
|
88 <td><a href="#SingleApplicationClient.errstr">errstr</a></td> |
|
89 <td>Public method to return a meaningful error string for the last error.</td> |
|
90 </tr> |
|
91 <tr> |
|
92 <td><a href="#SingleApplicationClient.processArgs">processArgs</a></td> |
|
93 <td>Public method to process the command line args passed to the UI.</td> |
|
94 </tr> |
|
95 <tr> |
|
96 <td><a href="#SingleApplicationClient.sendCommand">sendCommand</a></td> |
|
97 <td>Public method to send the command to the application server.</td> |
|
98 </tr> |
|
99 </table> |
|
100 <h3>Static Methods</h3> |
|
101 |
|
102 <table> |
|
103 <tr><td>None</td></tr> |
|
104 </table> |
|
105 |
|
106 <a NAME="SingleApplicationClient.__init__" ID="SingleApplicationClient.__init__"></a> |
|
107 <h4>SingleApplicationClient (Constructor)</h4> |
|
108 <b>SingleApplicationClient</b>(<i>name</i>) |
|
109 |
|
110 <p> |
|
111 Constructor |
|
112 </p> |
|
113 <dl> |
|
114 |
|
115 <dt><i>name</i></dt> |
|
116 <dd> |
|
117 name of the local server to connect to (string) |
|
118 </dd> |
|
119 </dl> |
|
120 <a NAME="SingleApplicationClient.connect" ID="SingleApplicationClient.connect"></a> |
|
121 <h4>SingleApplicationClient.connect</h4> |
|
122 <b>connect</b>(<i>timeout=10000</i>) |
|
123 |
|
124 <p> |
|
125 Public method to connect the single application client to its server. |
|
126 </p> |
|
127 <dl> |
|
128 |
|
129 <dt><i>timeout</i> (int)</dt> |
|
130 <dd> |
|
131 connection timeout value in milliseconds |
|
132 </dd> |
|
133 </dl> |
|
134 <dl> |
|
135 <dt>Return:</dt> |
|
136 <dd> |
|
137 value indicating success or an error number. Value is one of: |
|
138 <table> |
|
139 <tr><td>0</td><td>No application is running</td></tr> |
|
140 <tr><td>1</td><td>Application is already running</td></tr> |
|
141 </table> |
|
142 </dd> |
|
143 </dl> |
|
144 <a NAME="SingleApplicationClient.disconnect" ID="SingleApplicationClient.disconnect"></a> |
|
145 <h4>SingleApplicationClient.disconnect</h4> |
|
146 <b>disconnect</b>(<i></i>) |
|
147 |
|
148 <p> |
|
149 Public method to disconnect from the Single Appliocation server. |
|
150 </p> |
|
151 <a NAME="SingleApplicationClient.errstr" ID="SingleApplicationClient.errstr"></a> |
|
152 <h4>SingleApplicationClient.errstr</h4> |
|
153 <b>errstr</b>(<i></i>) |
|
154 |
|
155 <p> |
|
156 Public method to return a meaningful error string for the last error. |
|
157 </p> |
|
158 <dl> |
|
159 <dt>Return:</dt> |
|
160 <dd> |
|
161 error string for the last error (string) |
|
162 </dd> |
|
163 </dl> |
|
164 <a NAME="SingleApplicationClient.processArgs" ID="SingleApplicationClient.processArgs"></a> |
|
165 <h4>SingleApplicationClient.processArgs</h4> |
|
166 <b>processArgs</b>(<i>args</i>) |
|
167 |
|
168 <p> |
|
169 Public method to process the command line args passed to the UI. |
|
170 </p> |
|
171 <p> |
|
172 <b>Note</b>: This method must be overridden by subclasses. |
|
173 </p> |
|
174 <dl> |
|
175 |
|
176 <dt><i>args</i></dt> |
|
177 <dd> |
|
178 command line args (list of strings) |
|
179 </dd> |
|
180 </dl> |
|
181 <dl> |
|
182 |
|
183 <dt>Raises <b>RuntimeError</b>:</dt> |
|
184 <dd> |
|
185 raised to indicate that this method must be |
|
186 implemented by a subclass |
|
187 </dd> |
|
188 </dl> |
|
189 <a NAME="SingleApplicationClient.sendCommand" ID="SingleApplicationClient.sendCommand"></a> |
|
190 <h4>SingleApplicationClient.sendCommand</h4> |
|
191 <b>sendCommand</b>(<i>command, arguments</i>) |
|
192 |
|
193 <p> |
|
194 Public method to send the command to the application server. |
|
195 </p> |
|
196 <dl> |
|
197 |
|
198 <dt><i>command</i> (str)</dt> |
|
199 <dd> |
|
200 command to be sent to the server |
|
201 </dd> |
|
202 <dt><i>arguments</i> (list of str)</dt> |
|
203 <dd> |
|
204 list of command arguments |
|
205 </dd> |
|
206 </dl> |
|
207 <div align="right"><a href="#top">Up</a></div> |
|
208 <hr /> |
|
209 <hr /> |
|
210 <a NAME="SingleApplicationServer" ID="SingleApplicationServer"></a> |
|
211 <h2>SingleApplicationServer</h2> |
|
212 |
|
213 <p> |
|
214 Class implementing the single application server base class. |
|
215 </p> |
|
216 <h3>Derived from</h3> |
|
217 QLocalServer |
|
218 <h3>Class Attributes</h3> |
|
219 |
|
220 <table> |
|
221 <tr><td>None</td></tr> |
|
222 </table> |
|
223 <h3>Class Methods</h3> |
|
224 |
|
225 <table> |
|
226 <tr><td>None</td></tr> |
|
227 </table> |
|
228 <h3>Methods</h3> |
|
229 |
|
230 <table> |
|
231 |
|
232 <tr> |
|
233 <td><a href="#SingleApplicationServer.__init__">SingleApplicationServer</a></td> |
|
234 <td>Constructor</td> |
|
235 </tr> |
|
236 <tr> |
|
237 <td><a href="#SingleApplicationServer.__disconnected">__disconnected</a></td> |
|
238 <td>Private method to handle the closure of the socket.</td> |
|
239 </tr> |
|
240 <tr> |
|
241 <td><a href="#SingleApplicationServer.__newConnection">__newConnection</a></td> |
|
242 <td>Private slot to handle a new connection.</td> |
|
243 </tr> |
|
244 <tr> |
|
245 <td><a href="#SingleApplicationServer.__receiveJson">__receiveJson</a></td> |
|
246 <td>Private method to receive the data from the client.</td> |
|
247 </tr> |
|
248 <tr> |
|
249 <td><a href="#SingleApplicationServer.handleCommand">handleCommand</a></td> |
|
250 <td>Public slot to handle the command sent by the client.</td> |
|
251 </tr> |
|
252 <tr> |
|
253 <td><a href="#SingleApplicationServer.shutdown">shutdown</a></td> |
|
254 <td>Public method used to shut down the server.</td> |
|
255 </tr> |
|
256 </table> |
|
257 <h3>Static Methods</h3> |
|
258 |
|
259 <table> |
|
260 <tr><td>None</td></tr> |
|
261 </table> |
|
262 |
|
263 <a NAME="SingleApplicationServer.__init__" ID="SingleApplicationServer.__init__"></a> |
|
264 <h4>SingleApplicationServer (Constructor)</h4> |
|
265 <b>SingleApplicationServer</b>(<i>name</i>) |
|
266 |
|
267 <p> |
|
268 Constructor |
|
269 </p> |
|
270 <dl> |
|
271 |
|
272 <dt><i>name</i></dt> |
|
273 <dd> |
|
274 name this server is listening to (string) |
|
275 </dd> |
|
276 </dl> |
|
277 <a NAME="SingleApplicationServer.__disconnected" ID="SingleApplicationServer.__disconnected"></a> |
|
278 <h4>SingleApplicationServer.__disconnected</h4> |
|
279 <b>__disconnected</b>(<i></i>) |
|
280 |
|
281 <p> |
|
282 Private method to handle the closure of the socket. |
|
283 </p> |
|
284 <a NAME="SingleApplicationServer.__newConnection" ID="SingleApplicationServer.__newConnection"></a> |
|
285 <h4>SingleApplicationServer.__newConnection</h4> |
|
286 <b>__newConnection</b>(<i></i>) |
|
287 |
|
288 <p> |
|
289 Private slot to handle a new connection. |
|
290 </p> |
|
291 <a NAME="SingleApplicationServer.__receiveJson" ID="SingleApplicationServer.__receiveJson"></a> |
|
292 <h4>SingleApplicationServer.__receiveJson</h4> |
|
293 <b>__receiveJson</b>(<i></i>) |
|
294 |
|
295 <p> |
|
296 Private method to receive the data from the client. |
|
297 </p> |
|
298 <a NAME="SingleApplicationServer.handleCommand" ID="SingleApplicationServer.handleCommand"></a> |
|
299 <h4>SingleApplicationServer.handleCommand</h4> |
|
300 <b>handleCommand</b>(<i>command, arguments</i>) |
|
301 |
|
302 <p> |
|
303 Public slot to handle the command sent by the client. |
|
304 </p> |
|
305 <p> |
|
306 <b>Note</b>: This method must be overridden by subclasses. |
|
307 </p> |
|
308 <dl> |
|
309 |
|
310 <dt><i>command</i> (str)</dt> |
|
311 <dd> |
|
312 command sent by the client |
|
313 </dd> |
|
314 <dt><i>arguments</i> (list of str)</dt> |
|
315 <dd> |
|
316 list of command arguments |
|
317 </dd> |
|
318 </dl> |
|
319 <dl> |
|
320 |
|
321 <dt>Raises <b>RuntimeError</b>:</dt> |
|
322 <dd> |
|
323 raised to indicate that this method must be |
|
324 implemented by a subclass |
|
325 </dd> |
|
326 </dl> |
|
327 <a NAME="SingleApplicationServer.shutdown" ID="SingleApplicationServer.shutdown"></a> |
|
328 <h4>SingleApplicationServer.shutdown</h4> |
|
329 <b>shutdown</b>(<i></i>) |
|
330 |
|
331 <p> |
|
332 Public method used to shut down the server. |
|
333 </p> |
|
334 <div align="right"><a href="#top">Up</a></div> |
|
335 <hr /> |
|
336 </body></html> |