我做了一些研究并找到了答案,希望能将您引向正确的道路。解决方案看起来很相似。告诉我!
https://stackoverflow.com/a/62308032/14514188
https://github.com/rikulo/socket.io-client-dart#usage-flutter
In Flutter env. it only works with
dart:io websocket,
not with
dart:html websocket,
所以在这种情况下,您必须在创建套接字实例时添加 'transsports': ['websocket']。
IO.Socket socket = IO.io('http://localhost:3000', <String, dynamic>{
'transports': ['websocket'],
'extraHeaders': {'foo': 'bar'} // optional
});
The default Flask development server doesn't support websockets so you'll need to use another server. Thankfully it's simple to get eventlet working with Flask. All you should have to do is install the eventlet package using pip.
pip 安装小事件
一旦安装了 eventlet,socketio 将在运行服务器时检测并使用它。
You can use chrome to double check what transport method is being used. Open your chrome dev tools Ctrl+Shift+I in Windows and go to the Network tab. On each network request you should see either transport=polling or transport=websocket
https://stackoverflow.com/a/62308032/14514188