As you're using ServiceStack's Server Events you can just send a notification when a user logs out.
First you need to detect the User has logged out by implementing the OnLogout Session or Auth Event, e.g:
public class MyAuthEvents : AuthEvents
{
public IServerEvents ServerEvents { get; set; }
public override void OnLogout(IRequest httpReq,
IAuthSession session, IServiceBase authService)
{
var channel = "home"; //replace with channel tabs are subscribed to
var msg = "...";
ServerEvents.NotifyUserId(session.UserAuthId, "cmd.logout", msg, channel);
}
}
Notifying by UserId will send the notification to different tabs as well as browsers where the user is logged in. If you only want to send notifications to all tabs in just the 1 browser you can use the NotifySession(session.Id)
API instead.
To register your AuthEvents Handler with ServiceStack you just need to register it in the IOC, e.g:
container.RegisterAs<MyAuthEvents, IAuthEvents>();
Then handle the cmd.logout notification in your JavaScript ServerEvents Client, e.g:
$(source).handleServerEvents({
handlers: {
logout: function (msg) {
//Show AngularJS dialog
$mdDialog.alert({
title: 'Attention',
textContent: msg,
ok: 'Close'
});
},
//... Other custom handlers
}
});