util/stanza.lua
changeset 7761 2b305ec8c146
parent 7259 9fbb9fbf7e52
parent 7753 e58524240b30
child 8385 e5d00bf4a4d5
--- a/util/stanza.lua	Sun Nov 27 01:06:23 2016 +0100
+++ b/util/stanza.lua	Fri Dec 02 11:13:05 2016 +0100
@@ -14,6 +14,7 @@
 local s_match       =  string.match;
 local tostring      =      tostring;
 local setmetatable  =  setmetatable;
+local getmetatable  =  getmetatable;
 local pairs         =         pairs;
 local ipairs        =        ipairs;
 local type          =          type;
@@ -45,6 +46,10 @@
 	return setmetatable(stanza, stanza_mt);
 end
 
+local function is_stanza(s)
+	return getmetatable(s) == stanza_mt;
+end
+
 function stanza_mt:query(xmlns)
 	return self:tag("query", { xmlns = xmlns });
 end
@@ -422,6 +427,7 @@
 return {
 	stanza_mt = stanza_mt;
 	stanza = new_stanza;
+	is_stanza = is_stanza;
 	new_id = new_id;
 	preserialize = preserialize;
 	deserialize = deserialize;