Skip to content

Commit a0a7c55

Browse files
avinsridsualko
authored andcommitted
Add gone and inactive chat states (#2)
* Add functionality to send gone and inactive chat states * Look for gone or inactive states and accordingly trigger the state handler
1 parent fb0b5f5 commit a0a7c55

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

strophe.chatstates.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Strophe.addConnectionPlugin('chatstates',
3434
var composing = $(message).find('composing'),
3535
paused = $(message).find('paused'),
3636
active = $(message).find('active'),
37+
inactive = $(message).find('inactive'),
38+
gone = $(message).find('gone'),
3739
jid = $(message).attr('from');
3840

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

56+
if (inactive.length > 0)
57+
{
58+
$(document).trigger('inactive.chatstates', jid);
59+
}
60+
61+
if (gone.length > 0)
62+
{
63+
$(document).trigger('gone.chatstates', jid);
64+
}
65+
5466
return true;
5567
},
5668

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

84+
sendInactive: function(jid, type)
85+
{
86+
this._sendNotification(jid, type, 'inactive');
87+
},
88+
89+
sendGone: function(jid, type)
90+
{
91+
this._sendNotification(jid, type, 'gone');
92+
},
93+
7294
_sendNotification: function(jid, type, notification)
7395
{
7496
if (!type) type = 'chat';

0 commit comments

Comments
 (0)