I am using spatie and beyondcode's laravel-websockets. I have successfully installed it and able to run to this route by going to /laravel-websockets
My question is how to connect to a third party steam like in python . It seems to be very complicated in laravel with the involvement of Echo (Don't quite understand what is this for ) , Broadcasting and Pusher.
In python, this is what I do
import websocket
SOCKET = "wss://stream.binance.com:9443/ws/btcusdt@kline_1m"
def on_open(ws):
print("Open Connection")
def on_close(ws):
print("Close Connection")
def on_message(ws, message):
print(message)
try:
ws = websocket.WebSocketApp(
SOCKET, on_open=on_open, on_close=on_close, on_message=on_message
)
except:
print("Something went wrong with websocket connection")
finally:
ws.run_forever() //Get Data
How to achieve something similar in Laravel? Can't find anything that mentions how to do such thing in their documentation.