signalr_flutter
signalr_flutter copied to clipboard
isConnected() not working as expected
Hi. Thanks for adding isConnected()
feature, but its not working as expected
Before calling connect()
I check isConnected()
to avoid multi calls but isConnected()
always returns true even if signal r is not connected
And I know its not connected because by using hubCallback.call('hub_name', 'hub_method')
nothing happens and also Im not getting any call backs from hub
My Code
Map<String, String> header = {'username': '1'};
_signalR = SignalR('url', 'hub_name',
hubMethods: ['hub_method'],
statusChangeCallback: (status) => _onStatusChange(status),
hubCallback: (methodName, message) =>
_onHubCallback({methodName: message}),
headers: header);
bool isConnected = await _signalR.isConnected;
if (!isConnected) {
bool status = await _signalR.connect();
print("Signal Connecting : $status");
}else{
_signalR.hubCallback.call('hub_name', 'hub_method');
}
Well I tried the example app on both Android & iOS. isConnected
seems to be working fine for me.
Ok so I will test it again and let you know
this may prove that isConnected()
not working properly
this is my code:
SignalR signalR = SignalR(
'<Your server url here>',
"<Your hub name here>",
hubMethods: ["hubMethod1", "hubMethod2"]
statusChangeCallback: (status) => print(status),
hubCallback: (methodName, message) => print('MethodName = $methodName, Message = $message'));
while(await _signalR.isConnected){
_signalR.stop();
print('stop');
}
and the output is:
and it Does not stop printing 'stop'