|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric7.EricNetwork.EricJsonServer</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.EricNetwork.EricJsonServer</h1> |
|
10 |
|
11 <p> |
|
12 Module implementing the JSON based server base class. |
|
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="#EricJsonServer">EricJsonServer</a></td> |
|
25 <td>Class implementing a JSON based server base class.</td> |
|
26 </tr> |
|
27 </table> |
|
28 <h3>Functions</h3> |
|
29 |
|
30 <table> |
|
31 <tr><td>None</td></tr> |
|
32 </table> |
|
33 <hr /> |
|
34 <hr /> |
|
35 <a NAME="EricJsonServer" ID="EricJsonServer"></a> |
|
36 <h2>EricJsonServer</h2> |
|
37 |
|
38 <p> |
|
39 Class implementing a JSON based server base class. |
|
40 </p> |
|
41 <h3>Derived from</h3> |
|
42 QTcpServer |
|
43 <h3>Class Attributes</h3> |
|
44 |
|
45 <table> |
|
46 <tr><td>None</td></tr> |
|
47 </table> |
|
48 <h3>Class Methods</h3> |
|
49 |
|
50 <table> |
|
51 <tr><td>None</td></tr> |
|
52 </table> |
|
53 <h3>Methods</h3> |
|
54 |
|
55 <table> |
|
56 |
|
57 <tr> |
|
58 <td><a href="#EricJsonServer.__init__">EricJsonServer</a></td> |
|
59 <td>Constructor</td> |
|
60 </tr> |
|
61 <tr> |
|
62 <td><a href="#EricJsonServer.__handleDisconnect">__handleDisconnect</a></td> |
|
63 <td>Private slot handling a disconnect of the client.</td> |
|
64 </tr> |
|
65 <tr> |
|
66 <td><a href="#EricJsonServer.__receiveJson">__receiveJson</a></td> |
|
67 <td>Private slot handling received data from the client.</td> |
|
68 </tr> |
|
69 <tr> |
|
70 <td><a href="#EricJsonServer.connectionNames">connectionNames</a></td> |
|
71 <td>Public method to get the list of active connection names.</td> |
|
72 </tr> |
|
73 <tr> |
|
74 <td><a href="#EricJsonServer.handleCall">handleCall</a></td> |
|
75 <td>Public method to handle a method call from the client.</td> |
|
76 </tr> |
|
77 <tr> |
|
78 <td><a href="#EricJsonServer.handleNewConnection">handleNewConnection</a></td> |
|
79 <td>Public slot for new incoming connections from a client.</td> |
|
80 </tr> |
|
81 <tr> |
|
82 <td><a href="#EricJsonServer.sendJson">sendJson</a></td> |
|
83 <td>Public method to send a single command to a client.</td> |
|
84 </tr> |
|
85 <tr> |
|
86 <td><a href="#EricJsonServer.startClient">startClient</a></td> |
|
87 <td>Public method to start a client process.</td> |
|
88 </tr> |
|
89 <tr> |
|
90 <td><a href="#EricJsonServer.stopAllClients">stopAllClients</a></td> |
|
91 <td>Public method to stop all clients.</td> |
|
92 </tr> |
|
93 <tr> |
|
94 <td><a href="#EricJsonServer.stopClient">stopClient</a></td> |
|
95 <td>Public method to stop a client process.</td> |
|
96 </tr> |
|
97 </table> |
|
98 <h3>Static Methods</h3> |
|
99 |
|
100 <table> |
|
101 <tr><td>None</td></tr> |
|
102 </table> |
|
103 |
|
104 <a NAME="EricJsonServer.__init__" ID="EricJsonServer.__init__"></a> |
|
105 <h4>EricJsonServer (Constructor)</h4> |
|
106 <b>EricJsonServer</b>(<i>name="", multiplex=False, parent=None</i>) |
|
107 |
|
108 <p> |
|
109 Constructor |
|
110 </p> |
|
111 <dl> |
|
112 |
|
113 <dt><i>name</i> (str)</dt> |
|
114 <dd> |
|
115 name of the server (used for output only) |
|
116 </dd> |
|
117 <dt><i>multiplex</i> (bool)</dt> |
|
118 <dd> |
|
119 flag indicating a multiplexing server |
|
120 </dd> |
|
121 <dt><i>parent</i> (QObject)</dt> |
|
122 <dd> |
|
123 parent object |
|
124 </dd> |
|
125 </dl> |
|
126 <a NAME="EricJsonServer.__handleDisconnect" ID="EricJsonServer.__handleDisconnect"></a> |
|
127 <h4>EricJsonServer.__handleDisconnect</h4> |
|
128 <b>__handleDisconnect</b>(<i>idString</i>) |
|
129 |
|
130 <p> |
|
131 Private slot handling a disconnect of the client. |
|
132 </p> |
|
133 <dl> |
|
134 |
|
135 <dt><i>idString</i> (str)</dt> |
|
136 <dd> |
|
137 id of the connection been disconnected |
|
138 </dd> |
|
139 </dl> |
|
140 <a NAME="EricJsonServer.__receiveJson" ID="EricJsonServer.__receiveJson"></a> |
|
141 <h4>EricJsonServer.__receiveJson</h4> |
|
142 <b>__receiveJson</b>(<i>idString</i>) |
|
143 |
|
144 <p> |
|
145 Private slot handling received data from the client. |
|
146 </p> |
|
147 <dl> |
|
148 |
|
149 <dt><i>idString</i> (str)</dt> |
|
150 <dd> |
|
151 id of the connection |
|
152 </dd> |
|
153 </dl> |
|
154 <a NAME="EricJsonServer.connectionNames" ID="EricJsonServer.connectionNames"></a> |
|
155 <h4>EricJsonServer.connectionNames</h4> |
|
156 <b>connectionNames</b>(<i></i>) |
|
157 |
|
158 <p> |
|
159 Public method to get the list of active connection names. |
|
160 </p> |
|
161 <p> |
|
162 If this is not a multiplexing server, an empty list is returned. |
|
163 </p> |
|
164 <dl> |
|
165 <dt>Return:</dt> |
|
166 <dd> |
|
167 list of active connection names |
|
168 </dd> |
|
169 </dl> |
|
170 <dl> |
|
171 <dt>Return Type:</dt> |
|
172 <dd> |
|
173 list of str |
|
174 </dd> |
|
175 </dl> |
|
176 <a NAME="EricJsonServer.handleCall" ID="EricJsonServer.handleCall"></a> |
|
177 <h4>EricJsonServer.handleCall</h4> |
|
178 <b>handleCall</b>(<i>method, params</i>) |
|
179 |
|
180 <p> |
|
181 Public method to handle a method call from the client. |
|
182 </p> |
|
183 <p> |
|
184 Note: This is an empty implementation that must be overridden in |
|
185 derived classes. |
|
186 </p> |
|
187 <dl> |
|
188 |
|
189 <dt><i>method</i> (str)</dt> |
|
190 <dd> |
|
191 requested method name |
|
192 </dd> |
|
193 <dt><i>params</i> (dict)</dt> |
|
194 <dd> |
|
195 dictionary with method specific parameters |
|
196 </dd> |
|
197 </dl> |
|
198 <a NAME="EricJsonServer.handleNewConnection" ID="EricJsonServer.handleNewConnection"></a> |
|
199 <h4>EricJsonServer.handleNewConnection</h4> |
|
200 <b>handleNewConnection</b>(<i></i>) |
|
201 |
|
202 <p> |
|
203 Public slot for new incoming connections from a client. |
|
204 </p> |
|
205 <a NAME="EricJsonServer.sendJson" ID="EricJsonServer.sendJson"></a> |
|
206 <h4>EricJsonServer.sendJson</h4> |
|
207 <b>sendJson</b>(<i>command, params, flush=False, idString=""</i>) |
|
208 |
|
209 <p> |
|
210 Public method to send a single command to a client. |
|
211 </p> |
|
212 <dl> |
|
213 |
|
214 <dt><i>command</i> (str)</dt> |
|
215 <dd> |
|
216 command name to be sent |
|
217 </dd> |
|
218 <dt><i>params</i> (dict)</dt> |
|
219 <dd> |
|
220 dictionary of named parameters for the command |
|
221 </dd> |
|
222 <dt><i>flush</i> (bool)</dt> |
|
223 <dd> |
|
224 flag indicating to flush the data to the socket |
|
225 </dd> |
|
226 <dt><i>idString</i> (str)</dt> |
|
227 <dd> |
|
228 id of the connection to send data to |
|
229 </dd> |
|
230 </dl> |
|
231 <a NAME="EricJsonServer.startClient" ID="EricJsonServer.startClient"></a> |
|
232 <h4>EricJsonServer.startClient</h4> |
|
233 <b>startClient</b>(<i>interpreter, clientScript, clientArgs, idString="", environment=None</i>) |
|
234 |
|
235 <p> |
|
236 Public method to start a client process. |
|
237 </p> |
|
238 <dl> |
|
239 |
|
240 <dt><i>interpreter</i> (str)</dt> |
|
241 <dd> |
|
242 interpreter to be used for the client |
|
243 </dd> |
|
244 <dt><i>clientScript</i> (str)</dt> |
|
245 <dd> |
|
246 path to the client script |
|
247 </dd> |
|
248 <dt><i>clientArgs</i></dt> |
|
249 <dd> |
|
250 list of arguments for the client |
|
251 </dd> |
|
252 <dt><i>idString</i> (str)</dt> |
|
253 <dd> |
|
254 id of the client to be started |
|
255 </dd> |
|
256 <dt><i>environment</i> (dict)</dt> |
|
257 <dd> |
|
258 dictionary of environment settings to pass |
|
259 </dd> |
|
260 </dl> |
|
261 <dl> |
|
262 <dt>Return:</dt> |
|
263 <dd> |
|
264 flag indicating a successful client start and the exit code |
|
265 in case of an issue |
|
266 </dd> |
|
267 </dl> |
|
268 <dl> |
|
269 <dt>Return Type:</dt> |
|
270 <dd> |
|
271 bool, int |
|
272 </dd> |
|
273 </dl> |
|
274 <a NAME="EricJsonServer.stopAllClients" ID="EricJsonServer.stopAllClients"></a> |
|
275 <h4>EricJsonServer.stopAllClients</h4> |
|
276 <b>stopAllClients</b>(<i></i>) |
|
277 |
|
278 <p> |
|
279 Public method to stop all clients. |
|
280 </p> |
|
281 <a NAME="EricJsonServer.stopClient" ID="EricJsonServer.stopClient"></a> |
|
282 <h4>EricJsonServer.stopClient</h4> |
|
283 <b>stopClient</b>(<i>idString=""</i>) |
|
284 |
|
285 <p> |
|
286 Public method to stop a client process. |
|
287 </p> |
|
288 <dl> |
|
289 |
|
290 <dt><i>idString</i> (str)</dt> |
|
291 <dd> |
|
292 id of the client to be stopped |
|
293 </dd> |
|
294 </dl> |
|
295 <div align="right"><a href="#top">Up</a></div> |
|
296 <hr /> |
|
297 </body></html> |