Last post May 03, 2018 05:24 AM by Fei Han - MSFT
May 02, 2018 08:51 PM|Marco Prado|LINK
I am a beginner ASP.NET developer, and I'm having some problems using SignalR.
My goal is to develop a private chat between 2 people, doing so by upgrading that simple SignalR Chat demo that we can easily find on the Internet.
I am thinking about using the "Groups" function to do so, but I don't really know how to get started. I don't understand what I need to code on the server-side and on the client-side.
Can anyone help me?
May 03, 2018 05:24 AM|Fei Han - MSFT|LINK
Hi Marco Prado,
Welcome to ASP.NET forum.
y goal is to develop a private chat between 2 people
If you’d like to enable application user to send messages to other specific user, you can map users to connections and retain connection information (users&their connections) in external storage, such as database etc.
You need to override OnConnected() etc events, and in OnConnected() event you can get and store User- connectionID information in external storage. Then you can retrieve User-connectionID information from that external storage based on user name, and send
private message to that specific user based on ConnectionID.
Besides, as you mentioned, Single-user groups can also be used as approach to send message to specific user. You can read
this article to know how to Mapping SignalR Users to Connections and what is Single-user groups.