Skip to content

Commit

Permalink
Add gone and inactive chat states (#2)
Browse files Browse the repository at this point in the history
* Add functionality to send gone and inactive chat states

* Look for gone or inactive states and accordingly trigger the state handler
  • Loading branch information
avinsrid authored and sualko committed Mar 16, 2018
1 parent fb0b5f5 commit a0a7c55
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions strophe.chatstates.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Strophe.addConnectionPlugin('chatstates',
var composing = $(message).find('composing'),
paused = $(message).find('paused'),
active = $(message).find('active'),
inactive = $(message).find('inactive'),
gone = $(message).find('gone'),
jid = $(message).attr('from');

if (composing.length > 0)
Expand All @@ -51,6 +53,16 @@ Strophe.addConnectionPlugin('chatstates',
$(document).trigger('active.chatstates', jid);
}

if (inactive.length > 0)
{
$(document).trigger('inactive.chatstates', jid);
}

if (gone.length > 0)
{
$(document).trigger('gone.chatstates', jid);
}

return true;
},

Expand All @@ -69,6 +81,16 @@ Strophe.addConnectionPlugin('chatstates',
this._sendNotification(jid, type, 'paused');
},

sendInactive: function(jid, type)
{
this._sendNotification(jid, type, 'inactive');
},

sendGone: function(jid, type)
{
this._sendNotification(jid, type, 'gone');
},

_sendNotification: function(jid, type, notification)
{
if (!type) type = 'chat';
Expand Down

0 comments on commit a0a7c55

Please sign in to comment.