summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--omegle.py5
-rw-r--r--proxy.py13
2 files changed, 13 insertions, 5 deletions
diff --git a/omegle.py b/omegle.py
index 9a02fbb..ab3c2d0 100644
--- a/omegle.py
+++ b/omegle.py
@@ -9,6 +9,7 @@ from threading import Thread, Lock
class Timer(Thread):
def __init__(self,func,interval=0.50):
Thread.__init__(self)
+ self.logger = logging.getLogger(__name__ + "." + self.__class__.__name__)
self.func = func
self.interval = interval
@@ -19,6 +20,7 @@ class Timer(Thread):
while self.running:
self.func()
time.sleep(self.interval)
+ self.logger.debug("self.running == False")
def stop(self):
self.running = False
@@ -59,8 +61,8 @@ class OmegleChat(object):
self.timer.start()
def disconnect(self):
+ self.logger.debug("/disconnect")
self.timer.stop()
-
self.conn_lock.acquire()
self.conn.request("POST",
"/disconnect",
@@ -69,6 +71,7 @@ class OmegleChat(object):
r = self.conn.getresponse()
self.conn_lock.release()
body = r.read()
+ self.logger.debug("/disconnect sent. Read: %s" % body)
if body == "win":
self.is_connected = False
else:
diff --git a/proxy.py b/proxy.py
index 1711198..a5b0803 100644
--- a/proxy.py
+++ b/proxy.py
@@ -31,14 +31,19 @@ class OmegleProxyChat(OmegleChat):
print self.c("%s [EVT] %s Connection confirmed" % (time.strftime("%H:%M:%S"), self.name))
def on_typing(self):
print self.c("%s [EVT] %s is typing" % (time.strftime("%H:%M:%S"), self.name))
- self.partner.typing()
+ if self.partner.is_connected:
+ self.partner.typing()
def on_stopped_typing(self):
print self.c("%s [EVT] %s stopped typing" % (time.strftime("%H:%M:%S"), self.name))
- self.partner.stopped_typing()
+ if self.partner.is_connected:
+ self.partner.stopped_typing()
def on_disconnect(self):
print self.c("%s [EVT] %s disconnect" % (time.strftime("%H:%M:%S"), self.name))
+ if self.partner.is_connected:
+ self.partner.disconnect()
chat_lock.release()
+
logging.basicConfig(level=logging.DEBUG)
print "press ctrl-c to abort"
@@ -55,11 +60,11 @@ chat_lock.acquire()
try:
while True:
if chat_lock.acquire(0):
- break
+ print "One part disconnected, exiting"
else:
time.sleep(0.5)
except KeyboardInterrupt:
- pass
+ print "CTRL-C pressed, exiting"
if A.is_connected: A.disconnect()
if B.is_connected: B.disconnect()