We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
code:
class HomeState extends State<MyHomePage> { StringBuffer remoteMsg = StringBuffer(); HubConnection hubConnection = HubConnectionBuilder().withUrl('http://xxx.xxx/:8000/api/chatHub', HttpConnectionOptions( transport:HttpTransportType.none, logging: (level, message) => print("message: $message"), accessTokenFactory:() => Future.value("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiYWRtaW4iLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6ImFkbWluIiwianRpIjoiMSIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvZXhwaXJhdGlvbiI6IjYvNS8yMCAyOjQwOjMzIFBNIiwiaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS93cy8yMDA4LzA2L2lkZW50aXR5L2NsYWltcy9yb2xlIjoiQWRtaW4iLCJuYmYiOjE1OTEzMzU2MzMsImV4cCI6MTU5MTMzOTIzMywiaXNzIjoiT0EuUlNJLkJhY2tlbmQiLCJhdWQiOiJ3ciJ9.gKaIBDSF0MLJ5b6j7iiWKCeVvQJPMkqYJOuwPW_Yncw") )).build(); @override void initState(){ super.initState(); init(); } init() async { hubConnection.on('ReceiveMessage', (message) { setState(() { message.forEach((v) => remoteMsg.write(v)); print(message.toString()); }); }); try{ await hubConnection.start(); print("连接成功..."); }catch(e){ print("连接失败..."); } } @override Widget build(BuildContext context) { return Scaffold( body: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text("message from server: ${remoteMsg.toString()}"), TextField( decoration:InputDecoration( hintText:"Enter some text", ), onSubmitted:((v)async => await hubConnection.invoke('SendMessage', args: ['Flutter', v])), ), ], ), ); } }
The text was updated successfully, but these errors were encountered:
Possibly related to #14, also I don't think you need to return a Future to the accessTokenFactory.
accessTokenFactory
Sorry, something went wrong.
I added ''transport: HttpTransportType.longPolling,'' to HttpConnectionOptions solved my problem.
No branches or pull requests
code:
The text was updated successfully, but these errors were encountered: