1. Ivan Vučica
  2. TVZPong

Commits

Ivan Vučica  committed ee91aa7

Updated pong.js to sync with changes made in another project.

  • Participants
  • Parent commits b40f7de
  • Branches default

Comments (0)

Files changed (2)

File .hgsubstate

View file
  • Ignore whitespace
-52dade6f4749f3f42113d386a6b5dd880257842f zxmpp
+7eb4f827c27d8766ef9145a90f4556b8b379ff57 zxmpp

File pong.js

View file
  • Ignore whitespace
 
 function pong_rosterContactResourcesSupportingPong(jid)
 {
-    var presences = zxmpp.getPresencesForBareJid(jid);
+    var presences = zxmpp.getPresencesForBareJid(jid.split("/")[0]);
     var supportsPong = [];
     
     for (var resource in presences)
 
 
 ////////////////////////////////
+var pong_talkTo = false;
 function pong_invite(jid)
 {
     var resources = pong_rosterContactResourcesSupportingPong(jid);
         packet.send("poll");
     }
 }
+function pong_sendData(jid, data)
+{
+    //var resources = tuntap_rosterContactResourcesSupportingTunTap(jid);
+    
+    //for(var resourceId in resources)
+    {
+        //var resource = resources[resourceId];
+        var packet = new zxmpp.packet(zxmpp);
+        var message = new zxmpp.stanzaMessage(zxmpp);
+        message.appendToPacket(packet, zxmpp.fullJid, jid, "chat");// pass no body
+        var dataNode = packet.xml.createElementNS("http://tvzpong.vucica.net/protocol/", "data");
+
+        var dataText = packet.xml.createTextNode(data);
+        dataNode.appendChild(dataText);
+
+        packet.messageXML.appendChild(dataNode);
+        packet.send("poll");
+    }
+}
 
 ///////////////////////////////
 
     {
         for(var i in xml.childNodes)
         {
-            if(!xml || !xml.childNodes)
-            {
-                console.log("Wtf?");
-                break;
-            }
             var child = xml.childNodes[i];
             if(!child.nodeName) continue;
             
             this.zxmpp.util.easierAttrs(child);
-            console.log(child.extendedNodeName);
             switch(child.extendedNodeName)
             {
                     // handling of nonstandard messages
                     zxmppZ_onMessage(sender, fakeMessage);
                      */
                     alert("Invitation from " + messageStanza.from);
+		    pong_talkTo = messageStanza.from;
+                    break;
+		case "http://tvzpong.vucica.net/protocol/+data":
+                    //net_handler(child.firstChild.nodeValue);
                     break;
             }
         }