Skip to content

Commit

Permalink
Merge pull request JabbR#23 from Buildstarted/master
Browse files Browse the repository at this point in the history
Added window.unload event to automatically force users to leave the current room
  • Loading branch information
davidfowl committed Sep 4, 2011
2 parents 623590b + b95a591 commit 3a39975
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Chat/Chat.js
Expand Up @@ -235,11 +235,11 @@ $(function () {

chat.changeGravatar = function (currentUser) {
$('#u-' + currentUser.Id).replaceWith(
$('#new-user-template').tmpl({
name: currentUser.Name,
hash: currentUser.Hash,
id: currentUser.Id
})
$('#new-user-template').tmpl({
name: currentUser.Name,
hash: currentUser.Hash,
id: currentUser.Id
})
);

refreshUsers();
Expand All @@ -250,7 +250,7 @@ $(function () {
else {
addMessage(currentUser.Name + "'s gravatar changed.", 'notification');
}
}
};

chat.showCommands = function (commands) {
addMessage('<h3>Help</h3>');
Expand Down Expand Up @@ -314,6 +314,12 @@ $(function () {
document.title = 'SignalR Chat';
});

$(window).unload(function () {
if (chat.room)
chat.send("/leave");
//ignore errors
});

function updateUnread() {
if (!chat.focus) {
if (!chat.unread) {
Expand Down

0 comments on commit 3a39975

Please sign in to comment.