SignalR - Send message OnConnected

后端 未结 4 1638
半阙折子戏
半阙折子戏 2021-02-14 02:15

I\'ve been experimenting with SignalR today and It\'s really neat. Basically what I wanted to achieve is the following:

As soon as a device connects it should send a mes

4条回答
  •  闹比i
    闹比i (楼主)
    2021-02-14 02:58

    Unless I miss something from your question, the solution looks pretty simple to me, you just need to switch to using

    Clients.Caller.hello("Send to only the last one");
    

    instead of trying to understand yourself who's the last connected id. Same for the other ones, you can use:

    Clients.Others.hello("Send to everyone except last");
    

    You do not need all the logic you setup, those 2 lines do what you need, and they work inside OnConnected.

提交回复
热议问题