AS-Devs / signalr_flutter

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

hubCallBack not working #35

Open amendse opened 3 years ago

amendse commented 3 years ago

I have .net backend. My flutter app connecting with it successfully even invoke method and send message to server. but hubCallBack not working following is my code snippet

void initiateSignalR() async { signalR = SignalR('http://10.0.2.2:27506', "ChatHub", hubMethods: ["Send"], statusChangeCallback: _onStatusChange, hubCallback: _onNewMessage);

}

_onStatusChange(dynamic status) { print("Status " + status); if (mounted) { setState(() { _signalRStatus = status as String; }); } }

_onNewMessage(String? methodName, dynamic message) { print("IN message received"); print('MethodName = $methodName, Message = $message'); }

_buttonTapped() async { final res = await signalR.invokeMethod("send", arguments: ["flutter", "check"]).catchError((error) { print(error.toString()); }); final snackBar = SnackBar(content: Text('SignalR Method Response: $res')); }

yasngencc commented 3 years ago

merhaba; sunucu tarafındaki çağrıyı denemek için boş olarak gönderiyorsanız çalışmaz. SignalHub.Clients.Group(KullanıcıNo()).Mobil_TumListelerJson("BOŞ OLAMAZ")

amendse commented 3 years ago

this is my method in ChatHub

public string SendMsg(string name, string message) { // Call the broadcastMessage method to update clients. Clients.All.broadcastMessage(name, message);

        return message;
    }

On Wed, Jul 7, 2021 at 2:43 PM yenge35 @.***> wrote:

merhaba; sunucu tarafındaki çağrıyı denemek için boş olarak gönderiyorsanız çalışmaz. SignalHub.Clients.Group(KullanıcıNo()).Mobil_TumListelerJson("BOŞ OLAMAZ")

— 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/35#issuecomment-875435584, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACGJXHNDFNDHVEQ72H7Z7KLTWQLEDANCNFSM4754273Q .

yasngencc commented 3 years ago

bu .net için yazılmıştır. sizin proje core projesimi.

Johnson-Hsieh-66 commented 2 years ago

Try this.This works for me. void initiateSignalR() async { signalR = SignalR('http://10.0.2.2:27506/', "ChatHub", hubMethods: ["broadcastMessage"], statusChangeCallback: _onStatusChange, hubCallback: _onNewMessage); }

mohas commented 1 year ago

this is my method in ChatHub public string SendMsg(string name, string message) { // Call the broadcastMessage method to update clients. Clients.All.broadcastMessage(name, message); return message; } On Wed, Jul 7, 2021 at 2:43 PM yenge35 @.***> wrote: merhaba; sunucu tarafındaki çağrıyı denemek için boş olarak gönderiyorsanız çalışmaz. SignalHub.Clients.Group(KullanıcıNo()).Mobil_TumListelerJson("BOŞ OLAMAZ") — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#35 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACGJXHNDFNDHVEQ72H7Z7KLTWQLEDANCNFSM4754273Q .

Your method name in Hub is SendMsg while in your flutter app you are invoking "send"

gongwangjie commented 4 months ago

I am using everything normally in the debug environment. If I use it, I can connect to the server, but I cannot receive messages sent by the server. Have I encountered this situation?