From a0a7c55608c1c50843198ebf980947c280c542c6 Mon Sep 17 00:00:00 2001 From: "Blitz@vi" Date: Fri, 16 Mar 2018 08:15:43 -0400 Subject: [PATCH] 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 --- strophe.chatstates.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/strophe.chatstates.js b/strophe.chatstates.js index 1f9136e..43acb71 100644 --- a/strophe.chatstates.js +++ b/strophe.chatstates.js @@ -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) @@ -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; }, @@ -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';