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