Comparison

plugins/pubsub.lua @ 248:c4b55b0dc6ba

plugins.pubsub: Make the old functions wrap the new.
author Kim Alvefur <zash@zash.se>
date Mon, 28 Nov 2011 17:15:41 +0100
parent 222:3c257afd68e7
child 250:a5ac643a7fd6
comparison
equal deleted inserted replaced
247:7c58c16efa3e 248:c4b55b0dc6ba
27 end 27 end
28 end); 28 end);
29 return true; 29 return true;
30 end 30 end
31 31
32 -- COMPAT
32 function pubsub:create(server, node, callback) 33 function pubsub:create(server, node, callback)
33 self.stream:warn("pubsub:create() is deprecated, " 34 return self:server(server):node(node):create(nil, callback);
34 .."you should use pubsub:service(%q):node(%q):create() instead\n%s", server or "", node, debug.traceback());
35 local create = verse.iq({ to = server, type = "set" })
36 :tag("pubsub", { xmlns = xmlns_pubsub })
37 :tag("create", { node = node }):up()
38 self.stream:send_iq(create, function (result)
39 if callback then
40 if result.attr.type == "result" then
41 callback(true);
42 else
43 callback(false, result:get_error());
44 end
45 end
46 end
47 );
48 end 35 end
49 36
50 function pubsub:subscribe(server, node, jid, callback) 37 function pubsub:subscribe(server, node, jid, callback)
51 self.stream:warn("pubsub:subscribe() is deprecated, " 38 return self:server(server):node(node):subscribe(jid, nil, callback);
52 .."you should use pubsub:service(%q):node(%q):subscribe(jid) instead\n%s", server or "", node, debug.traceback());
53 self.stream:send_iq(verse.iq({ to = server, type = "set" })
54 :tag("pubsub", { xmlns = xmlns_pubsub })
55 :tag("subscribe", { node = node, jid = jid or jid_bare(self.stream.jid) })
56 , function (result)
57 if callback then
58 if result.attr.type == "result" then
59 callback(true);
60 else
61 callback(false, result:get_error());
62 end
63 end
64 end
65 );
66 end 39 end
67 40
68 function pubsub:publish(server, node, id, item, callback) 41 function pubsub:publish(server, node, id, item, callback)
69 self.stream:warn("pubsub:publish() is deprecated, " 42 return self:server(server):node(node):publish(id, nil, item, callback);
70 .."you should use pubsub:service(%q):node(%q):publish() instead\n%s", server or "", node, debug.traceback());
71 self.stream:send_iq(verse.iq({ to = server, type = "set" })
72 :tag("pubsub", { xmlns = xmlns_pubsub })
73 :tag("publish", { node = node })
74 :tag("item", { id = id })
75 :add_child(item)
76 , function (result)
77 if callback then
78 if result.attr.type == "result" then
79 callback(true);
80 else
81 callback(false, result:get_error());
82 end
83 end
84 end
85 );
86 end 43 end
87 44
88 -------------------------------------------------------------------------- 45 --------------------------------------------------------------------------
89 ---------------------New and improved PubSub interface-------------------- 46 ---------------------New and improved PubSub interface--------------------
90 -------------------------------------------------------------------------- 47 --------------------------------------------------------------------------