如何使用asp.net signalR向特定组中的特定用户发送消息 [英] how can I send message to specific user in specific group using asp.net signalR

查看:54
本文介绍了如何使用asp.net signalR向特定组中的特定用户发送消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以向聊天中的所有群组发送消息

I can send message to all group in chat

 return context.Clients.Group(sGrp).recieveNotification(message, user, chatid, uuid);

我可以向聊天中的所有群组发送消息

I can send message to all group in chat

return context.Clients.User(currentuser).seenyou(myname);

当我向特定组中的特定用户发送消息时出现的问题有办法吗?

the problem when i send message to specific user in specific group is there is way to do this .

推荐答案

向特定用户发送消息的唯一方法是通过用户的连接ID寻址该用户.在这种情况下,他是否属于特定组并不重要.除此之外,没有可以迭代的内置列表,您需要自己管理这些引用.

The only way to send a message to a specific user is by addressing the user by its connection Id. In this case it doesn't matter if he is in a specific group or not. Other than that there's no such thing as a built-in list, that you can iterate on, you need to manage those references by yourself.

当然,如果所需的用户是发件人,则可以使用 Clients.Caller .

Of course, if the desired user is the sender, you can use Clients.Caller.

这篇关于如何使用asp.net signalR向特定组中的特定用户发送消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆