0

I'm trying out SignalR and I have a question.

For example I know how it works and i can make a simple chat, but i'm interested how can i create conversation between 2 ppl?

For example yes i could know 2 ppl connection ids and send messages to them but also if other ppl send messages to those connection ids, then it is not chat 1 vs 1.

What i want to have something like a space for 2 ppl only, so connection id user 1 and connetion id user 2. So that if user 3 cant get messages sent to the same connection.

More information:

Imagine a user can write message to another user, but the other user can be offline, so there is a button on each users profile, so when user (ME) decides to write to user (YOU), ill go to his page and click send messages.

Then a window opens and connection starts. So then on connected i'll do => Group.Add(Context.ConnectionId, ME) so i send messages, if user is offline ill save them to database, but if user is there, he gets notified, he goes to the page clicks "send messages", same window is opened, so this user (YOU) joins group (ME) and there is connection good. BUT what if (ME) have closed window and is disconnected, so user (YOU) sends messsages, user (ME) gets notified and opesn the window and now he will say Group.Add(..., YOU), but user YOU is still in the group ME.

So i dont know if it was clear but this way i cannot maintain same group ... :/ there will be complexity in that :(

And method on connected ... i cannot send there any kind of parameters etc, basically you can join group your own

Alnedru
  • 2,573
  • 9
  • 50
  • 88
  • http://www.asp.net/signalr/overview/signalr-20/hubs-api/working-with-groups – halter73 Feb 05 '14 at 20:06
  • yes i thought about that, but i have a problem, how the user knows the group name? i mean you cannot know if the group already exists, because it is not really a chat. There is a messsages, when you click on it, then you join ... – Alnedru Feb 05 '14 at 20:10
  • You can use a DB to keep track of which rooms exist and which users are in the room. – halter73 Feb 05 '14 at 22:34
  • ok for example if i could do that but even on method OnConnected() i cannot pass any paramteres .... how can i specify to which group user have to join? – Alnedru Feb 06 '14 at 10:03
  • You could have your clients call a custom hub method, perhaps called "initialize" or "join", that can take whatever parameters you want. You can also read query string parameters in OnConnected: http://stackoverflow.com/questions/15528221/passing-token-through-http-headers-signalr#answer-15531839 – halter73 Feb 06 '14 at 19:18

0 Answers0