[Xmpp4js-commit] SF.net SVN: xmpp4js:[767] trunk/src/main/javascript/PacketFilter.js
Status: Beta
Brought to you by:
h-iverson
|
From: <h-i...@us...> - 2008-08-04 23:00:16
|
Revision: 767
http://xmpp4js.svn.sourceforge.net/xmpp4js/?rev=767&view=rev
Author: h-iverson
Date: 2008-08-04 23:00:23 +0000 (Mon, 04 Aug 2008)
Log Message:
-----------
added PacketTypeFilter
Modified Paths:
--------------
trunk/src/main/javascript/PacketFilter.js
Modified: trunk/src/main/javascript/PacketFilter.js
===================================================================
--- trunk/src/main/javascript/PacketFilter.js 2008-08-04 22:29:58 UTC (rev 766)
+++ trunk/src/main/javascript/PacketFilter.js 2008-08-04 23:00:23 UTC (rev 767)
@@ -132,7 +132,7 @@
Xmpp4Js.Lang.extend(Xmpp4Js.PacketFilter.AllPacketFilter, Xmpp4Js.PacketFilter.PacketFilter, Xmpp4Js.PacketFilter.AllPacketFilter.prototype);
/**
- * Filters for packets of a particular type. The type is given as a Class object, so example types would:
+ * Filters for packets of a particular class. The given should be a constructor, so example types would:
* * Packet.Message
* * Packet.IQ
* * Packet.Presence
@@ -154,6 +154,29 @@
Xmpp4Js.Lang.extend(Xmpp4Js.PacketFilter.PacketClassFilter, Xmpp4Js.PacketFilter.PacketFilter, Xmpp4Js.PacketFilter.PacketClassFilter.prototype);
+ /**
+ * Filters for packets of a particular type. The type is given as a string.
+ * This can be used for any packet class.
+ *
+ * @constructor
+ * @extends Xmpp4Js.PacketFilter.PacketFilter
+ */
+Xmpp4Js.PacketFilter.PacketTypeFilter = function(type) {
+ Xmpp4Js.PacketFilter.PacketTypeFilter.superclass.constructor.apply(this, arguments);
+
+ this.type = type;
+}
+
+Xmpp4Js.PacketFilter.PacketTypeFilter.prototype = {
+ accept: function(packet) {
+ return packet.getType() == this.type;
+ }
+};
+
+
+Xmpp4Js.Lang.extend(Xmpp4Js.PacketFilter.PacketTypeFilter, Xmpp4Js.PacketFilter.PacketFilter, Xmpp4Js.PacketFilter.PacketTypeFilter.prototype);
+
+
/**
* Filters for packets with a particular packet ID.
* @constructor
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|