Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Side by Side Diff: tools/devtools_auto/third_party/websocket-client/examples/echoapp_client.py

Issue 10825463: Initial checkin for devtools-based automation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 import websocket
2 import thread
3 import time
4 import sys
5
6 def on_message(ws, message):
7 print message
8
9 def on_error(ws, error):
10 print error
11
12 def on_close(ws):
13 print "### closed ###"
14
15 def on_open(ws):
16 def run(*args):
17 for i in range(3):
18 # send the message, then wait
19 # so thread doesnt exit and socket
20 # isnt closed
21 ws.send("Hello %d" % i)
22 time.sleep(1)
23
24 time.sleep(1)
25 ws.close()
26 print "Thread terminating..."
27
28 thread.start_new_thread(run, ())
29
30 if __name__ == "__main__":
31 websocket.enableTrace(True)
32 if len(sys.argv) < 2:
33 host = "ws://echo.websocket.org/"
34 else:
35 host = sys.argv[1]
36 ws = websocket.WebSocketApp(host,
37 on_message = on_message,
38 on_error = on_error,
39 on_close = on_close)
40 ws.on_open = on_open
41 ws.run_forever()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698