signalr_flutter icon indicating copy to clipboard operation
signalr_flutter copied to clipboard

hubCallBack not working

Open amendse opened this issue 3 years ago • 6 comments

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')); }

amendse avatar Jul 07 '21 05:07 amendse

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")

yasngencc avatar Jul 07 '21 09:07 yasngencc

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 .

amendse avatar Jul 07 '21 09:07 amendse

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

yasngencc avatar Jul 07 '21 10:07 yasngencc

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

Johnson-Hsieh-66 avatar Jun 09 '22 02:06 Johnson-Hsieh-66

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"

mohas avatar Apr 20 '23 09:04 mohas

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?

gongwangjie avatar Apr 18 '24 15:04 gongwangjie