diff --git a/index.html b/index.html
index 9831560..d02b41a 100644
--- a/index.html
+++ b/index.html
@@ -12,11 +12,11 @@
function sendMsg() {
msg = document.getElementById("input").value;
- window.webxdc.sendUpdate('someone typed "'+msg+'"', {"addr": window.webxdc.selfAddr(), "msg": msg});
+ window.webxdc.sendUpdate('someone typed "'+msg+'"', {"name": window.webxdc.selfName(), "msg": msg});
}
function receiveUpdate(update) {
- document.getElementById('output').innerHTML += "<" + update.payload.addr + "> " + update.payload.msg + "
";
+ document.getElementById('output').innerHTML += "<" + update.payload.name + "> " + update.payload.msg + "
";
}
window.webxdc.setUpdateListener(receiveUpdate);
diff --git a/webxdc.js b/webxdc.js
index 6980897..2b90865 100644
--- a/webxdc.js
+++ b/webxdc.js
@@ -6,6 +6,7 @@ window.webxdc = (() => {
return {
selfAddr: () => window.xdcSelfAddr || "device0@local.host",
+ selfName: () => window.xdcSelfName || "device0",
setUpdateListener: (cb) => (window.xdcUpdateListener = cb),
getAllUpdates: () => {
return JSON.parse(
@@ -47,7 +48,8 @@ function addPeer() {
var xdcChild = window.open(window.location);
var xdcRoot = getXdcRoot();
xdcChild.xdcRoot = xdcRoot;
- xdcChild.xdcSelfAddr = "device" + xdcRoot.allXdcWindows.length + "@local.host";
+ xdcChild.xdcSelfName = "device" + getAllXdcWindows().length;
+ xdcChild.xdcSelfAddr = xdcChild.xdcSelfName + "@local.host";
xdcRoot.allXdcWindows.push(xdcChild);
}