Flutter 如何使用Flatter应用程序使用APP_ID、APP_密钥和APP_SECRET连接到web套接字
如何使用APP_ID、APP_密钥和APP_SECRET与flift应用程序连接到web套接字。好的,我的错,你可以查看此api参考Flutter 如何使用Flatter应用程序使用APP_ID、APP_密钥和APP_SECRET连接到web套接字,flutter,dart,websocket,Flutter,Dart,Websocket,如何使用APP_ID、APP_密钥和APP_SECRET与flift应用程序连接到web套接字。好的,我的错,你可以查看此api参考 我使用了Flatter\u pusher\u客户端和laravel\u echo,但得到了'java.security.cert.CertPathValidatorException:找不到证书路径的信任锚点错误 我的代码 PusherOptions pusherOptions = PusherOptions( encrypted: true, host:
我使用了Flatter\u pusher\u客户端和laravel\u echo,但得到了'java.security.cert.CertPathValidatorException:找不到证书路径的信任锚点错误 我的代码
PusherOptions pusherOptions = PusherOptions(
encrypted: true,
host: 'socket.abcd.com',
cluster: 'mt1',
port: 6001,
);
FlutterPusher flutterPusher = FlutterPusher(
'PUSHER_APP_KEY',
pusherOptions,
enableLogging: true,
);
Echo echo = Echo({
'broadcaster': 'pusher',
'client': flutterPusher,
'wssHost': 'socket.abcd.com',
'wssPort': 6001,
'disableStats': true,
'forceTLS': true,
'autoConnect': true,
'enabledTransports': ['ws', 'wss'],
});
flutterPusher.connect(
onConnectionStateChange:
(FPC.ConnectionStateChange connectionStateChange) {
print(
'PUSHER CONNECTION STATE CHANGE C: ${connectionStateChange.previousState} -> ${connectionStateChange.currentState}',
);
},
onError: (FPC.ConnectionError connectionError) {
print(
'PUSHER CONNECTION ERROR C: ${connectionError.code} ${connectionError.exception} ${connectionError.message}');
},
);
echo.join('chat')
..here((user) => print('ECHO USER: user'))
..listen('NewMessage', (event) {
print('ECHO MESSAGE: $event');
});
WebSocket和HTTP是完全不同的协议。
http
包和dio
包都不能帮助OP解决使用WebSocket的问题。到哪里?以什么形式?为了什么?你需要更具体一点。还有,你自己试过吗?您是否在pub上查看了与websockets相关的包并遵循了它们的文档?