0

I have a situation where a user can modify an Excel like grid schedule online. I would like to be able to show a message stating that the schedule is being modified in another window. However, how can I do this with a window open, and if the previous window was closed with SignalR. For other sessions I just want to state another user is modifying the schedule.

Mike Flynn
  • 22,342
  • 54
  • 182
  • 341
  • Pretty vague what exactly you are asking. Can you provide a simple scenario? – AD.Net Jul 08 '14 at 01:52
  • View schedule page, open tab and navigate to same schedule page, but show message the schedule page is already being viewed. – Mike Flynn Jul 08 '14 at 02:00

1 Answers1

1

It might be easiest to use localStorage to communicate between multiple tabs/windows a single user has open: http://www.codediesel.com/javascript/sharing-messages-and-data-across-windows-using-localstorage/

You can listen for the storage event which is triggered on every window a user has open on your site when you call localStorage.setItem or localStorage.removeItem.

Of course, it would still make sense to use SignalR to notify other users.

If you cannot use the localStorage API for some reason, you can still use SignalR to send a message to every window the user has open by using Clients.User(userName).... inside your Hub. By default, userName should match your user's IPrincipal.Identity.Name, but you can register your own IUserIdProvider to customize this: http://www.asp.net/signalr/overview/signalr-20/hubs-api/mapping-users-to-connections#IUserIdProvider

halter73
  • 15,059
  • 3
  • 49
  • 60