|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric6.Cooperation.Connection</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><a NAME="top" ID="top"></a> |
|
22 <h1>eric6.Cooperation.Connection</h1> |
|
23 <p> |
|
24 Module implementing a class representing a peer connection. |
|
25 </p> |
|
26 <h3>Global Attributes</h3> |
|
27 <table> |
|
28 <tr><td>MaxBufferSize</td></tr><tr><td>PingInterval</td></tr><tr><td>PongTimeout</td></tr><tr><td>SeparatorToken</td></tr><tr><td>SeparatorToken_b</td></tr><tr><td>TransferTimeout</td></tr> |
|
29 </table> |
|
30 <h3>Classes</h3> |
|
31 <table> |
|
32 <tr> |
|
33 <td><a href="#Connection">Connection</a></td> |
|
34 <td>Class representing a peer connection.</td> |
|
35 </tr> |
|
36 </table> |
|
37 <h3>Functions</h3> |
|
38 <table> |
|
39 <tr><td>None</td></tr> |
|
40 </table> |
|
41 <hr /><hr /> |
|
42 <a NAME="Connection" ID="Connection"></a> |
|
43 <h2>Connection</h2> |
|
44 <p> |
|
45 Class representing a peer connection. |
|
46 </p><h3>Signals</h3> |
|
47 <dl> |
|
48 <dt>editorCommand(hash, fn, message)</dt> |
|
49 <dd> |
|
50 emitted after an editor command |
|
51 has arrived (string, string, string) |
|
52 </dd><dt>getParticipants()</dt> |
|
53 <dd> |
|
54 emitted after a get participants message has |
|
55 arrived |
|
56 </dd><dt>newMessage(user, message)</dt> |
|
57 <dd> |
|
58 emitted after a new message has |
|
59 arrived (string, string) |
|
60 </dd><dt>participants(participants)</dt> |
|
61 <dd> |
|
62 emitted after the list of participants |
|
63 has arrived (list of strings of "host:port") |
|
64 </dd><dt>readyForUse()</dt> |
|
65 <dd> |
|
66 emitted when the connection is ready for use |
|
67 </dd><dt>rejected(message)</dt> |
|
68 <dd> |
|
69 emitted after a connection has been rejected |
|
70 (string) |
|
71 </dd> |
|
72 </dl> |
|
73 <h3>Derived from</h3> |
|
74 QTcpSocket |
|
75 <h3>Class Attributes</h3> |
|
76 <table> |
|
77 <tr><td>Editor</td></tr><tr><td>GetParticipants</td></tr><tr><td>Greeting</td></tr><tr><td>Participants</td></tr><tr><td>Ping</td></tr><tr><td>PlainText</td></tr><tr><td>Pong</td></tr><tr><td>ProtocolEditor</td></tr><tr><td>ProtocolGetParticipants</td></tr><tr><td>ProtocolGreeting</td></tr><tr><td>ProtocolMessage</td></tr><tr><td>ProtocolParticipants</td></tr><tr><td>ProtocolPing</td></tr><tr><td>ProtocolPong</td></tr><tr><td>ReadingGreeting</td></tr><tr><td>ReadyForUse</td></tr><tr><td>Undefined</td></tr><tr><td>WaitingForGreeting</td></tr> |
|
78 </table> |
|
79 <h3>Class Methods</h3> |
|
80 <table> |
|
81 <tr><td>None</td></tr> |
|
82 </table> |
|
83 <h3>Methods</h3> |
|
84 <table> |
|
85 <tr> |
|
86 <td><a href="#Connection.__init__">Connection</a></td> |
|
87 <td>Constructor</td> |
|
88 </tr><tr> |
|
89 <td><a href="#Connection.__dataLengthForCurrentDataType">__dataLengthForCurrentDataType</a></td> |
|
90 <td>Private method to get the data length for the current data type.</td> |
|
91 </tr><tr> |
|
92 <td><a href="#Connection.__disconnected">__disconnected</a></td> |
|
93 <td>Private slot to handle the connection being dropped.</td> |
|
94 </tr><tr> |
|
95 <td><a href="#Connection.__hasEnoughData">__hasEnoughData</a></td> |
|
96 <td>Private method to check, if enough data is available.</td> |
|
97 </tr><tr> |
|
98 <td><a href="#Connection.__processData">__processData</a></td> |
|
99 <td>Private method to process the received data.</td> |
|
100 </tr><tr> |
|
101 <td><a href="#Connection.__processReadyRead">__processReadyRead</a></td> |
|
102 <td>Private slot to handle the readyRead signal.</td> |
|
103 </tr><tr> |
|
104 <td><a href="#Connection.__readDataIntoBuffer">__readDataIntoBuffer</a></td> |
|
105 <td>Private method to read some data into the buffer.</td> |
|
106 </tr><tr> |
|
107 <td><a href="#Connection.__readProtocolHeader">__readProtocolHeader</a></td> |
|
108 <td>Private method to read the protocol header.</td> |
|
109 </tr><tr> |
|
110 <td><a href="#Connection.__sendGreetingMessage">__sendGreetingMessage</a></td> |
|
111 <td>Private slot to send a greeting message.</td> |
|
112 </tr><tr> |
|
113 <td><a href="#Connection.__sendPing">__sendPing</a></td> |
|
114 <td>Private slot to send a ping message.</td> |
|
115 </tr><tr> |
|
116 <td><a href="#Connection.name">name</a></td> |
|
117 <td>Public method to get the connection name.</td> |
|
118 </tr><tr> |
|
119 <td><a href="#Connection.sendEditorCommand">sendEditorCommand</a></td> |
|
120 <td>Public method to send an editor command.</td> |
|
121 </tr><tr> |
|
122 <td><a href="#Connection.sendGetParticipants">sendGetParticipants</a></td> |
|
123 <td>Public method to request a list of participants.</td> |
|
124 </tr><tr> |
|
125 <td><a href="#Connection.sendMessage">sendMessage</a></td> |
|
126 <td>Public method to send a message.</td> |
|
127 </tr><tr> |
|
128 <td><a href="#Connection.sendParticipants">sendParticipants</a></td> |
|
129 <td>Public method to send the list of participants.</td> |
|
130 </tr><tr> |
|
131 <td><a href="#Connection.serverPort">serverPort</a></td> |
|
132 <td>Public method to get the server port.</td> |
|
133 </tr><tr> |
|
134 <td><a href="#Connection.setClient">setClient</a></td> |
|
135 <td>Public method to set the reference to the cooperation client.</td> |
|
136 </tr><tr> |
|
137 <td><a href="#Connection.setGreetingMessage">setGreetingMessage</a></td> |
|
138 <td>Public method to set the greeting message.</td> |
|
139 </tr><tr> |
|
140 <td><a href="#Connection.timerEvent">timerEvent</a></td> |
|
141 <td>Protected method to handle timer events.</td> |
|
142 </tr> |
|
143 </table> |
|
144 <h3>Static Methods</h3> |
|
145 <table> |
|
146 <tr><td>None</td></tr> |
|
147 </table> |
|
148 <a NAME="Connection.__init__" ID="Connection.__init__"></a> |
|
149 <h4>Connection (Constructor)</h4> |
|
150 <b>Connection</b>(<i>parent=None</i>) |
|
151 <p> |
|
152 Constructor |
|
153 </p><dl> |
|
154 <dt><i>parent</i></dt> |
|
155 <dd> |
|
156 referenec to the parent object (QObject) |
|
157 </dd> |
|
158 </dl><a NAME="Connection.__dataLengthForCurrentDataType" ID="Connection.__dataLengthForCurrentDataType"></a> |
|
159 <h4>Connection.__dataLengthForCurrentDataType</h4> |
|
160 <b>__dataLengthForCurrentDataType</b>(<i></i>) |
|
161 <p> |
|
162 Private method to get the data length for the current data type. |
|
163 </p><dl> |
|
164 <dt>Returns:</dt> |
|
165 <dd> |
|
166 data length (integer) |
|
167 </dd> |
|
168 </dl><a NAME="Connection.__disconnected" ID="Connection.__disconnected"></a> |
|
169 <h4>Connection.__disconnected</h4> |
|
170 <b>__disconnected</b>(<i></i>) |
|
171 <p> |
|
172 Private slot to handle the connection being dropped. |
|
173 </p><a NAME="Connection.__hasEnoughData" ID="Connection.__hasEnoughData"></a> |
|
174 <h4>Connection.__hasEnoughData</h4> |
|
175 <b>__hasEnoughData</b>(<i></i>) |
|
176 <p> |
|
177 Private method to check, if enough data is available. |
|
178 </p><dl> |
|
179 <dt>Returns:</dt> |
|
180 <dd> |
|
181 flag indicating availability of enough data (boolean) |
|
182 </dd> |
|
183 </dl><a NAME="Connection.__processData" ID="Connection.__processData"></a> |
|
184 <h4>Connection.__processData</h4> |
|
185 <b>__processData</b>(<i></i>) |
|
186 <p> |
|
187 Private method to process the received data. |
|
188 </p><a NAME="Connection.__processReadyRead" ID="Connection.__processReadyRead"></a> |
|
189 <h4>Connection.__processReadyRead</h4> |
|
190 <b>__processReadyRead</b>(<i></i>) |
|
191 <p> |
|
192 Private slot to handle the readyRead signal. |
|
193 </p><a NAME="Connection.__readDataIntoBuffer" ID="Connection.__readDataIntoBuffer"></a> |
|
194 <h4>Connection.__readDataIntoBuffer</h4> |
|
195 <b>__readDataIntoBuffer</b>(<i>maxSize=MaxBufferSize</i>) |
|
196 <p> |
|
197 Private method to read some data into the buffer. |
|
198 </p><dl> |
|
199 <dt><i>maxSize</i></dt> |
|
200 <dd> |
|
201 maximum size of data to read (integer) |
|
202 </dd> |
|
203 </dl><dl> |
|
204 <dt>Returns:</dt> |
|
205 <dd> |
|
206 size of data read (integer) |
|
207 </dd> |
|
208 </dl><a NAME="Connection.__readProtocolHeader" ID="Connection.__readProtocolHeader"></a> |
|
209 <h4>Connection.__readProtocolHeader</h4> |
|
210 <b>__readProtocolHeader</b>(<i></i>) |
|
211 <p> |
|
212 Private method to read the protocol header. |
|
213 </p><dl> |
|
214 <dt>Returns:</dt> |
|
215 <dd> |
|
216 flag indicating a successful read (boolean) |
|
217 </dd> |
|
218 </dl><a NAME="Connection.__sendGreetingMessage" ID="Connection.__sendGreetingMessage"></a> |
|
219 <h4>Connection.__sendGreetingMessage</h4> |
|
220 <b>__sendGreetingMessage</b>(<i></i>) |
|
221 <p> |
|
222 Private slot to send a greeting message. |
|
223 </p><a NAME="Connection.__sendPing" ID="Connection.__sendPing"></a> |
|
224 <h4>Connection.__sendPing</h4> |
|
225 <b>__sendPing</b>(<i></i>) |
|
226 <p> |
|
227 Private slot to send a ping message. |
|
228 </p><a NAME="Connection.name" ID="Connection.name"></a> |
|
229 <h4>Connection.name</h4> |
|
230 <b>name</b>(<i></i>) |
|
231 <p> |
|
232 Public method to get the connection name. |
|
233 </p><dl> |
|
234 <dt>Returns:</dt> |
|
235 <dd> |
|
236 connection name (string) |
|
237 </dd> |
|
238 </dl><a NAME="Connection.sendEditorCommand" ID="Connection.sendEditorCommand"></a> |
|
239 <h4>Connection.sendEditorCommand</h4> |
|
240 <b>sendEditorCommand</b>(<i>projectHash, filename, message</i>) |
|
241 <p> |
|
242 Public method to send an editor command. |
|
243 </p><dl> |
|
244 <dt><i>projectHash</i></dt> |
|
245 <dd> |
|
246 hash of the project (string) |
|
247 </dd><dt><i>filename</i></dt> |
|
248 <dd> |
|
249 project relative universal file name of |
|
250 the sending editor (string) |
|
251 </dd><dt><i>message</i></dt> |
|
252 <dd> |
|
253 editor command to be sent (string) |
|
254 </dd> |
|
255 </dl><a NAME="Connection.sendGetParticipants" ID="Connection.sendGetParticipants"></a> |
|
256 <h4>Connection.sendGetParticipants</h4> |
|
257 <b>sendGetParticipants</b>(<i></i>) |
|
258 <p> |
|
259 Public method to request a list of participants. |
|
260 </p><a NAME="Connection.sendMessage" ID="Connection.sendMessage"></a> |
|
261 <h4>Connection.sendMessage</h4> |
|
262 <b>sendMessage</b>(<i>message</i>) |
|
263 <p> |
|
264 Public method to send a message. |
|
265 </p><dl> |
|
266 <dt><i>message</i></dt> |
|
267 <dd> |
|
268 message to be sent (string) |
|
269 </dd> |
|
270 </dl><dl> |
|
271 <dt>Returns:</dt> |
|
272 <dd> |
|
273 flag indicating a successful send (boolean) |
|
274 </dd> |
|
275 </dl><a NAME="Connection.sendParticipants" ID="Connection.sendParticipants"></a> |
|
276 <h4>Connection.sendParticipants</h4> |
|
277 <b>sendParticipants</b>(<i>participants</i>) |
|
278 <p> |
|
279 Public method to send the list of participants. |
|
280 </p><dl> |
|
281 <dt><i>participants</i></dt> |
|
282 <dd> |
|
283 list of participants (list of strings of |
|
284 "host:port") |
|
285 </dd> |
|
286 </dl><a NAME="Connection.serverPort" ID="Connection.serverPort"></a> |
|
287 <h4>Connection.serverPort</h4> |
|
288 <b>serverPort</b>(<i></i>) |
|
289 <p> |
|
290 Public method to get the server port. |
|
291 </p><dl> |
|
292 <dt>Returns:</dt> |
|
293 <dd> |
|
294 server port (integer) |
|
295 </dd> |
|
296 </dl><a NAME="Connection.setClient" ID="Connection.setClient"></a> |
|
297 <h4>Connection.setClient</h4> |
|
298 <b>setClient</b>(<i>client</i>) |
|
299 <p> |
|
300 Public method to set the reference to the cooperation client. |
|
301 </p><dl> |
|
302 <dt><i>client</i></dt> |
|
303 <dd> |
|
304 reference to the cooperation client (CooperationClient) |
|
305 </dd> |
|
306 </dl><a NAME="Connection.setGreetingMessage" ID="Connection.setGreetingMessage"></a> |
|
307 <h4>Connection.setGreetingMessage</h4> |
|
308 <b>setGreetingMessage</b>(<i>message, serverPort</i>) |
|
309 <p> |
|
310 Public method to set the greeting message. |
|
311 </p><dl> |
|
312 <dt><i>message</i></dt> |
|
313 <dd> |
|
314 greeting message (string) |
|
315 </dd><dt><i>serverPort</i></dt> |
|
316 <dd> |
|
317 port number to include in the message (integer) |
|
318 </dd> |
|
319 </dl><a NAME="Connection.timerEvent" ID="Connection.timerEvent"></a> |
|
320 <h4>Connection.timerEvent</h4> |
|
321 <b>timerEvent</b>(<i>evt</i>) |
|
322 <p> |
|
323 Protected method to handle timer events. |
|
324 </p><dl> |
|
325 <dt><i>evt</i></dt> |
|
326 <dd> |
|
327 reference to the timer event (QTimerEvent) |
|
328 </dd> |
|
329 </dl> |
|
330 <div align="right"><a href="#top">Up</a></div> |
|
331 <hr /> |
|
332 </body></html> |