summaryrefslogtreecommitdiff
path: root/test.py
diff options
context:
space:
mode:
authoryvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd>2009-05-27 20:14:11 +0000
committeryvesf <yvesf@d0e8fea9-7529-0410-93fb-d39fd5b9c1dd>2009-05-27 20:14:11 +0000
commit4698adc0927976fb854120c83494a6af877081fd (patch)
tree5d681560ccc4bf6e10beee611efa2c1af63380d9 /test.py
parent99c698893ee66a24e0c3eb1004c0c4ce44cb16fe (diff)
downloadomegle-4698adc0927976fb854120c83494a6af877081fd.tar.gz
omegle-4698adc0927976fb854120c83494a6af877081fd.zip
foobar
git-svn-id: http://xapek.org/svn/common/omegle@1013 d0e8fea9-7529-0410-93fb-d39fd5b9c1dd
Diffstat (limited to 'test.py')
-rw-r--r--test.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/test.py b/test.py
index 19564bb..1e9d6c2 100644
--- a/test.py
+++ b/test.py
@@ -2,6 +2,7 @@ import sys
import httplib
import urllib
import time
+import json
from threading import Thread, Lock
class Timer(Thread):
@@ -103,7 +104,33 @@ class OmegleChat(object):
def on_event(self,conn,body):
- print "Event: %s" % body
+ try:
+ data_set=json.read(body)
+ for data in data_set:
+ if data[0] == "typing":
+ self.on_typing()
+ elif data[0] == "gotMessage" and data.__len__() == 2:
+ self.on_message(data[1])
+ elif data[0] == "connected":
+ self.on_connect()
+ elif data[0] == "strangerDisconnected":
+ self.timer.stop()
+ self.on__disconnect()
+ elif data[0] == "waiting":
+ pass #unhandled
+ else:
+ print "Unknown JSON Data: %s" % body
+ except json.ReadException:
+ print "Json ReadException. Body: %s" % body
+
+ def on_message(self,message):
+ print "<<< %s" % message
+ def on_connect(self):
+ print "Connected"
+ def on_typing(self):
+ print "Stranger typing"
+ def on_disconnect(self):
+ print "Stranger Disconnectect"
chat = OmegleChat()
chat.start()
@@ -118,5 +145,6 @@ while 1==1:
chat.disconnect()
break
else:
+ print ">>> %s" % cmd
chat.send(cmd)