Created
July 26, 2012 14:53
-
-
Save sznurek/3182513 to your computer and use it in GitHub Desktop.
Second try
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Authenticator: | |
def __init__(self, sock): | |
self.sock = sock | |
self.login = None | |
self.pass = None | |
self.to_send = "LOGIN" | |
self.to_read = None | |
def on_write(self): | |
if self.to_send == "LOGIN": | |
self.to_read = "LOGIN" | |
elif self.to_send == "PASS": | |
self.to_read = "PASS" | |
self.sock.send(self.to_send) | |
self.to_send = None | |
def on_read(self): | |
data = self.sock.recv(2 ** 10) | |
if self.to_read == ... | |
self.to_read = None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment