changeset 9:d3b37bbb2b88 default tip master

Support multiple participants.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 02 Feb 2012 16:37:28 +0100
parents 7b2ca4d5af6d
children
files script2.js
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/script2.js
+++ b/script2.js
@@ -261,7 +261,7 @@ var offerState = function(to, type, sid)
   conn.send(message);
 };
 
-var sendState = function(sid) {
+var sendState = function(sid, from) {
   var doc = documents[sid];
   var initialState = doc.createState([]).map(function(element) {
     return Lightstring.DOM2XML(element);
@@ -283,6 +283,8 @@ var sendState = function(sid) {
     conn.send(message);
   } else { // host
     for (var jid in doc.participants) {
+      if (from == jid)
+        continue;
       var type = doc.participants[jid];
       var message = "<message to='" + jid + "'" +
                             " type='" + type + "'>" +
@@ -351,6 +353,8 @@ conn.on('message/' + Lightstring.ns['sxe
       var elements = payload.children;
       doc.empty();
       doc.processState(from, elements);
+      if (doc.host === conn.jid.full)
+        sendState(sid, from);
       break;
     default:
       var elements = sxe.children;