如何在 Laravel 中连接第三方套接字流

问题描述

我正在使用 spatie 和 Beyondcode 的 laravel-websockets。我已经成功安装了它并且能够通过转到 /laravel-websockets

运行到这条路线

enter image description here

我的问题是如何像在 python 中那样连接到第三方 Steam。在laravel中好像很复杂,有Echo(不太明白这是为了什么),broadcasting和Pusher的参与。

在python中,这就是我所做的

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

如何在 Laravel 中实现类似的东西?在他们的文档中找不到任何提及如何执行此类操作的内容

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)