import websocket

def on_message(ws, message):
     print(message)

def on_error(ws, error):
     print(error)

def on_close(ws):
     print("WebSocket connection has been closed")

def on_open(ws):
     print("WebSocket connection is open")
     # You can send messages after the connection is established
     ws.send("Hello, WebSocket!")

if __name__ == "__main__":
     websocket.enableTrace(True) # Enable debugging information
     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()
Likes(1)

Comment list count 0 Comments

No Comments