diff options
author | yvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd> | 2009-05-28 08:19:11 +0000 |
---|---|---|
committer | yvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd> | 2009-05-28 08:19:11 +0000 |
commit | 148facadf4b6ca036f1f4d52ed82108a665550b4 (patch) | |
tree | 9f5124885bae8fc2ee7baae6de72d2b08f10b9fe /omegle.py | |
parent | 423fe90162a1c097b02bb8add604cdb9d95a04d0 (diff) | |
download | omegle-148facadf4b6ca036f1f4d52ed82108a665550b4.tar.gz omegle-148facadf4b6ca036f1f4d52ed82108a665550b4.zip |
blah
git-svn-id: http://xapek.org/svn/common/omegle@1022 d0e8fea9-7529-0410-93fb-d39fd5b9c1dd
Diffstat (limited to 'omegle.py')
-rw-r--r-- | omegle.py | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -40,6 +40,7 @@ class OmegleChat(object): self.timer = Timer(self.events, poll_interval) self.logger = logging.getLogger(__name__ + "." + self.__class__.__name__) + self.is_connected = False def start(self): self.conn_lock.acquire() @@ -68,7 +69,9 @@ class OmegleChat(object): r = self.conn.getresponse() self.conn_lock.release() body = r.read() - if body != "win": + if body == "win": + self.is_connected = False + else: raise Exception("/disconnect; Bad response: %s" % body) def events(self): @@ -136,14 +139,16 @@ class OmegleChat(object): elif data[0] == "gotMessage" and data.__len__() == 2: self.on_message(data[1]) elif data[0] == "connected": + self.is_connected = True self.on_connect() elif data[0] == "strangerDisconnected": + self.is_connected = False self.timer.stop() self.on_disconnect() elif data[0] == "stoppedTyping": self.on_stopped_typing() elif data[0] == "waiting": - pass #unhandled + self.on_wait() else: self.logger.error("Unknown JSON Data: %s" % body) except json.ReadException: @@ -159,6 +164,8 @@ class OmegleChat(object): self.logger.info("Stranger stopped typing") def on_disconnect(self): self.logger.info("Stranger Disconnectet") + def on_wait(self): + self.logger.info("Server sent [\"waiting\"]") if __name__ == "__main__": |