When you use ServiceStack Server Services , you can simply send a notification when a user logs off.
First you need to detect that the User has logged out by running an OnLogout session or Auth event , for example:
public class MyAuthEvents : AuthEvents { public IServerEvents ServerEvents { get; set; } public override void OnLogout(IRequest httpReq, IAuthSession session, IServiceBase authService) { var channel = "home";
A notification using UserId will send a notification to different tabs, as well as to browsers in which the user is logged in. If you want to send notifications only to all tabs in only 1 browser, you can use the NotifySession(session.Id) API.
To register an AuthEvents handler with a ServiceStack, you just need to register it in the IOC, for example:
container.RegisterAs<MyAuthEvents, IAuthEvents>();
Then handle the cmd.logout notification in the JavaScript ServerEvents client , for example:
$(source).handleServerEvents({ handlers: { logout: function (msg) { //Show AngularJS dialog $mdDialog.alert({ title: 'Attention', textContent: msg, ok: 'Close' }); }, //... Other custom handlers } });
mythz source share