Mercurial > eldonilo > lightstring
comparison plugins/presence.js @ 48:a118a7822410
Fix presence plugin.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Wed, 01 Feb 2012 02:05:03 +0100 |
parents | 8b739d4e094b |
children | 03ccf507ecda |
comparison
equal
deleted
inserted
replaced
47:ea276b47c555 | 48:a118a7822410 |
---|---|
21 //Presence// http://xmpp.org/rfcs/rfc6121.html#presence | 21 //Presence// http://xmpp.org/rfcs/rfc6121.html#presence |
22 //////////// | 22 //////////// |
23 (function() { | 23 (function() { |
24 var legal_types = ['error', 'probe', 'subscribe', 'subscribed', 'unavailable', 'unsubscribe', 'unsubscribed']; | 24 var legal_types = ['error', 'probe', 'subscribe', 'subscribed', 'unavailable', 'unsubscribe', 'unsubscribed']; |
25 | 25 |
26 Lightstring.stanza.presence = function(object) { | 26 Lightstring.plugins['presence'] = { |
27 if (object) { | 27 stanzas: { |
28 var payloads = ""; | 28 presence: function(object) { |
29 var attributs = ""; | 29 if (object) { |
30 if (object.type && legal_types.indexOf(object.type) !== -1) | 30 var payloads = ""; |
31 attributs += " type='" + object.type + "'"; | 31 var attributs = ""; |
32 if (object.type && legal_types.indexOf(object.type) !== -1) | |
33 attributs += " type='" + object.type + "'"; | |
32 | 34 |
33 if (object.priority) | 35 if (object.priority) |
34 payloads += "<priority>" + object.priority + "</priority>"; | 36 payloads += "<priority>" + object.priority + "</priority>"; |
35 | 37 |
36 if (object.show) | 38 if (object.show) |
37 payloads += "<show>" + object.show + "</show>"; | 39 payloads += "<show>" + object.show + "</show>"; |
38 | 40 |
39 if (object.status) | 41 if (object.status) |
40 payloads += "<status>" + object.status + "</status>"; | 42 payloads += "<status>" + object.status + "</status>"; |
41 | 43 |
42 if (object.payload) | 44 if (object.payload) |
43 payloads += object.payload; | 45 payloads += object.payload; |
44 | 46 |
45 if (payloads) | 47 if (payloads) |
46 return "<presence" + attributs + ">" + payloads + "</presence>"; | 48 return "<presence" + attributs + ">" + payloads + "</presence>"; |
47 else | 49 else |
48 return "<presence" + attributs + "/>"; | 50 return "<presence" + attributs + "/>"; |
49 | 51 |
50 } else | 52 } else |
51 return "<presence/>"; | 53 return "<presence/>"; |
52 }; | 54 }, |
53 | 55 }, |
54 Lightstring.presence = function(aConnection, aObject) { | 56 methods: { |
55 aConnection.send(Lightstring.stanza.presence(aObject)); | 57 presence: function(aObject) { |
58 this.send(Lightstring.stanzas.presence(aObject)); | |
59 } | |
60 } | |
56 }; | 61 }; |
57 })(); | 62 })(); |