AS-Devs / signalr_flutter

A flutter plugin for .net SignalR client.
https://pub.dev/packages/signalr_flutter
MIT License
18 stars 28 forks source link

iOS Simulator unable to connect signalR Hub #20

Closed naren-mavshack closed 3 years ago

naren-mavshack commented 3 years ago

Hi, Try to connect with iOS , it is now working it show connecting and then after it is Disconnected.

SignalR Connecting. Current Status: Optional("Connecting") Error: Optional(["message": Error during negotiation request.])

And in Android it is connected but does not listen channel messages , we try but hubCallback is never called

yasngencc commented 3 years ago

merhaba; kodlarınızı görebilirmiyim.

naren-mavshack commented 3 years ago

Hi,

I am using below code in my dart project.

class SignalRClient { static SignalRClient _client;

static SignalRClient getInstance() { if (_client == null) { client = SignalRClient.(); } return _client; }

SignalRClient._();

SignalR _signalR; String _signalRStatus;

Future connectToHub() async { _signalR = SignalR(kSingalRUrl, kHubName, statusChangeCallback: _onStatusChange, hubCallback: _onNewMessage);

bool connected = await _signalR.connect();

print("Signal Connecting : $connected");

return connected; }

_onStatusChange(status) async { print("statusChangeCallback: " + status);

_signalRStatus = status;

if (status == "Connected") { await subscribedToChannel(methodName); await subscribedToChannel(event1); await subscribedToChannel(event2); await subscribedToChannel(channelDispatch); await subscribedToChannel(channel1); await subscribedToChannel(channel2); await subscribedToChannel(channelKey);

List arguments = [channelKey, channelDispatch]; var r = await _signalR.invokeMethod(methodName, arguments: arguments); print("Invoke $methodName: $arguments ==> $r");

arguments = [channelKey, channel2]; r = await _signalR.invokeMethod(methodName, arguments: arguments); print("Invoke $methodName: $arguments ==> $r");

arguments = [channelKey, channel1]; r = await _signalR.invokeMethod(methodName, arguments: arguments); print("Invoke $methodName: $arguments ==> $r"); } else if (status == "Reconnecting") { } else if (status == "Disconnected") {} }

_onNewMessage(message) { // if (event == 'web_booking') {} print("\n\n\n\nHurrey New Message received : \n$message\n\n"); }

Future disconnectToHub() async { _signalR.stop(); }

Future subscribedToChannel(String channel) async { if (_signalRStatus != SignalRStatus.connected) { _signalR.reconnect(); }

_signalR.subscribeToHubMethod(channel);

print("SignalR Subscribed: $channel"); }

Future sendTest() async { var result = await _signalR.invokeMethod('send', arguments: [channelKey, channelDispatch, "event", "Message"]); print(result); } }

On Sat, 16 Jan 2021 at 02:44, yenge35 notifications@github.com wrote:

merhaba; kodlarınızı görebilirmiyim.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AS-Devs/signalr_flutter/issues/20#issuecomment-761200527, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIZOKCMY4546UCW5UEZVSPTS2CV3HANCNFSM4WDYPJFQ .

-- Thanks & Regards [image: IPMovers IT Ptd. Ltd.] Narendra Vaishnav Tech. Lead | Mobile Plateform Tel: +91-7307817025 IPMovers IT Ptd. Ltd. http://ipmovers.com/ www.ipmovers.com http://ipmovers.com/en.html

6th Floor, STPI Building, C-184,Industrial Area, Phase­-VIII­ A, Sector 75, SAS Nagar, Punjab 160071, India. https://goo.gl/maps/BjL31aTaNUo A part of the Mavshack Group https://www.mavshack.se/

yasngencc commented 3 years ago

Clients.All.methodName("Message")

sunucu tarafından böyle bir kod ile "methodName" tetiklenebilir.

yasngencc commented 3 years ago

await subscribedToChannel(methodName); await subscribedToChannel(event1); await subscribedToChannel(event2);

tırnak işareti içerisinde olacak

await subscribedToChannel("methodName"); await subscribedToChannel("event1"); await subscribedToChannel("event2");

AyonAB commented 3 years ago

Try using the latest version and let me know if the problem is still there. For me its working fine in simulator.

naren-mavshack commented 3 years ago

Due to time constraints we have implemented own native code , and I am not able to follow the same thread so I am closing this issue for the time. Thanks