- prepare for py3
This commit is contained in:
@@ -3,10 +3,10 @@ import websocket
|
||||
if __name__ == "__main__":
|
||||
websocket.enableTrace(True)
|
||||
ws = websocket.create_connection("ws://echo.websocket.org/")
|
||||
print "Sending 'Hello, World'..."
|
||||
print("Sending 'Hello, World'...")
|
||||
ws.send("Hello, World")
|
||||
print "Sent"
|
||||
print "Receiving..."
|
||||
result = ws.recv()
|
||||
print "Received '%s'" % result
|
||||
print("Sent")
|
||||
print("Receiving...")
|
||||
result = ws.recv()
|
||||
print("Received '%s'" % result)
|
||||
ws.close()
|
||||
|
@@ -3,14 +3,18 @@ import thread
|
||||
import time
|
||||
import sys
|
||||
|
||||
|
||||
def on_message(ws, message):
|
||||
print message
|
||||
print(message)
|
||||
|
||||
|
||||
def on_error(ws, error):
|
||||
print error
|
||||
print(error)
|
||||
|
||||
|
||||
def on_close(ws):
|
||||
print "### closed ###"
|
||||
print("### closed ###")
|
||||
|
||||
|
||||
def on_open(ws):
|
||||
def run(*args):
|
||||
@@ -23,7 +27,7 @@ def on_open(ws):
|
||||
|
||||
time.sleep(1)
|
||||
ws.close()
|
||||
print "Thread terminating..."
|
||||
print("Thread terminating...")
|
||||
|
||||
thread.start_new_thread(run, ())
|
||||
|
||||
|
@@ -765,10 +765,10 @@ class WebSocketApp(object):
|
||||
if __name__ == "__main__":
|
||||
enableTrace(True)
|
||||
ws = create_connection("ws://echo.websocket.org/")
|
||||
print "Sending 'Hello, World'..."
|
||||
print("Sending 'Hello, World'...")
|
||||
ws.send("Hello, World")
|
||||
print "Sent"
|
||||
print "Receiving..."
|
||||
print("Sent")
|
||||
print("Receiving...")
|
||||
result = ws.recv()
|
||||
print "Received '%s'" % result
|
||||
print("Received '%s'" % result)
|
||||
ws.close()
|
||||
|
Reference in New Issue
Block a user