Skip to content

Instantly share code, notes, and snippets.

@icehongssii
Created January 25, 2019 02:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icehongssii/6e1ff926b3c5265191ead6ccca1ebd3d to your computer and use it in GitHub Desktop.
Save icehongssii/6e1ff926b3c5265191ead6ccca1ebd3d to your computer and use it in GitHub Desktop.
import websocket
def on_message(ws, message):
print(message)
def on_error(ws, error):
print(error)
def on_close(ws):
print("### closed ###")
def on_open(ws):
ws.send("Hello %d" % i)
if __name__ == "__main__":
websocket.enableTrace(True)
ws = websocket.WebSocketApp("ws://echo.websocket.org/",
on_message = on_message,
on_error = on_error,
on_close = on_close)
ws.on_open = on_open
ws.run_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment