0

I want to know if specific User open specific page like Chat page because user may be online but not open specific page.

I am using ASP.NET MVC 5 with SignalR

The case is that, there is one to one Chat page between two specific users suppose A & B, and when user A send message to user B, there are option:

1- user B open chat page, so he will receive message in chat page by signalr but not receive notification

2- user B is online but not open chat page, so he will receive notification in notification menu in layout page but not receive message in chat page

So finally i need to know if user open chat page inside the SendMessage method in ChatHub class at the server to decide the option

Send message in Hub class at server:

public void SendMessage(string msg, string userId)
{
    Clients.Client(connectionId).receiveMessage(chatMsge);

    // here i want to check if user is in chat page or not
   if(user not in chat page)
   {
         Clients.Client(connectionId).receiveNotify(chatMsge);
   }

}

the problem is that i need to check the condition in the sendMessage method, so i need to some method go to client and return with the result

I am searched a lot of time but cannot find what i need

The code of signalr found in Layout page

No error message it is logic of signalR i want to understand

MrMustafa
  • 305
  • 3
  • 16
  • What exactly do you want to do with that information? Because what you want to do with it will inform the better way to answer your question – Bosco Jul 27 '19 at 08:17
  • I updated the question for you, i hope u understand my case, thanks – MrMustafa Jul 27 '19 at 11:00

1 Answers1

0

If you want to check that specific user open specific page, just add one signalR method for that page, whenever any user load that page you can ping signalR method with userinfo as well as page information.

it will be good if you provide more info so you can get better help.

Vishal modi
  • 1,571
  • 2
  • 12
  • 20
  • 1
    then first you need to do some analysis, because nobody will going to serve you ready made code. here you can get help to solve your problems not whole code. – Vishal modi Jul 27 '19 at 11:05