| OLD | NEW |
| 1 # Author: Trevor Perrin |
| 2 # See the LICENSE file for legal information regarding use of this file. |
| 3 |
| 1 """ | 4 """ |
| 2 A state machine for using TLS Lite with asynchronous I/O. | 5 A state machine for using TLS Lite with asynchronous I/O. |
| 3 """ | 6 """ |
| 4 | 7 |
| 5 class AsyncStateMachine: | 8 class AsyncStateMachine: |
| 6 """ | 9 """ |
| 7 This is an abstract class that's used to integrate TLS Lite with | 10 This is an abstract class that's used to integrate TLS Lite with |
| 8 asyncore and Twisted. | 11 asyncore and Twisted. |
| 9 | 12 |
| 10 This class signals wantsReadsEvent() and wantsWriteEvent(). When | 13 This class signals wantsReadsEvent() and wantsWriteEvent(). When |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 self.handshaker = handshaker | 199 self.handshaker = handshaker |
| 197 self._doHandshakeOp() | 200 self._doHandshakeOp() |
| 198 except: | 201 except: |
| 199 self._clear() | 202 self._clear() |
| 200 raise | 203 raise |
| 201 | 204 |
| 202 def setServerHandshakeOp(self, **args): | 205 def setServerHandshakeOp(self, **args): |
| 203 """Start a handshake operation. | 206 """Start a handshake operation. |
| 204 | 207 |
| 205 The arguments passed to this function will be forwarded to | 208 The arguments passed to this function will be forwarded to |
| 206 L{tlslite.TLSConnection.TLSConnection.handshakeServerAsync}. | 209 L{tlslite.tlsconnection.TLSConnection.handshakeServerAsync}. |
| 207 """ | 210 """ |
| 208 handshaker = self.tlsConnection.handshakeServerAsync(**args) | 211 handshaker = self.tlsConnection.handshakeServerAsync(**args) |
| 209 self.setHandshakeOp(handshaker) | 212 self.setHandshakeOp(handshaker) |
| 210 | 213 |
| 211 def setCloseOp(self): | 214 def setCloseOp(self): |
| 212 """Start a close operation. | 215 """Start a close operation. |
| 213 """ | 216 """ |
| 214 try: | 217 try: |
| 215 self._checkAssert(0) | 218 self._checkAssert(0) |
| 216 self.closer = self.tlsConnection.closeAsync() | 219 self.closer = self.tlsConnection.closeAsync() |
| 217 self._doCloseOp() | 220 self._doCloseOp() |
| 218 except: | 221 except: |
| 219 self._clear() | 222 self._clear() |
| 220 raise | 223 raise |
| 221 | 224 |
| 222 def setWriteOp(self, writeBuffer): | 225 def setWriteOp(self, writeBuffer): |
| 223 """Start a write operation. | 226 """Start a write operation. |
| 224 | 227 |
| 225 @type writeBuffer: str | 228 @type writeBuffer: str |
| 226 @param writeBuffer: The string to transmit. | 229 @param writeBuffer: The string to transmit. |
| 227 """ | 230 """ |
| 228 try: | 231 try: |
| 229 self._checkAssert(0) | 232 self._checkAssert(0) |
| 230 self.writer = self.tlsConnection.writeAsync(writeBuffer) | 233 self.writer = self.tlsConnection.writeAsync(writeBuffer) |
| 231 self._doWriteOp() | 234 self._doWriteOp() |
| 232 except: | 235 except: |
| 233 self._clear() | 236 self._clear() |
| 234 raise | 237 raise |
| 235 | 238 |
| OLD | NEW |