Comparing version 0.3.0 to 0.3.1
20
canop.js
@@ -385,3 +385,3 @@ (function (root, factory) { | ||
this.base = params.base || 0; // Most recent known canon operation index. | ||
this.localId = 0; // Identifier of the current machine. | ||
this.id = 0; // Identifier of the current machine. | ||
this.local = new Operation(); // Operation for local changes. | ||
@@ -423,6 +423,6 @@ this.sent = new Operation(); // Operation for changes sent but not acknowledged. | ||
try { | ||
if (self.localId === 0) { | ||
if (self.id === 0) { | ||
self.send(JSON.stringify([PROTOCOL_PLEASE, PROTOCOL_VERSION])); | ||
} else { | ||
self.send(JSON.stringify([PROTOCOL_SINCE, self.localId, self.base])); | ||
self.send(JSON.stringify([PROTOCOL_SINCE, self.id, self.base])); | ||
} | ||
@@ -696,9 +696,9 @@ self.clientState = STATE_LOADING; | ||
reset: function(data, base, localId) { | ||
reset: function(data, base, id) { | ||
this.local = new Operation(); | ||
this.sent = new Operation(); | ||
this.canon = new Operation(); | ||
this.localId = localId; | ||
this.id = id; | ||
if (!this.disableData) { this.data = data; } | ||
this.receiveChange([PROTOCOL_DELTA, [], [[[base, localId, 0], [actions.set, data]]]]); | ||
this.receiveChange([PROTOCOL_DELTA, [], [[[base, id, 0], [actions.set, data]]]]); | ||
}, | ||
@@ -864,3 +864,3 @@ localToSent: function() { | ||
return this.local.add(action[1], action[2], action[3], | ||
this.base, this.localId); | ||
this.base, this.id); | ||
}, | ||
@@ -871,3 +871,3 @@ // action: [actions.stringAdd, path, …params] | ||
return this.local.remove(action[1], action[2], action[3], | ||
this.base, this.localId); | ||
this.base, this.id); | ||
}, | ||
@@ -881,3 +881,3 @@ | ||
try { | ||
this.send(JSON.stringify([PROTOCOL_SIGNAL, this.localId, content])); | ||
this.send(JSON.stringify([PROTOCOL_SIGNAL, this.id, content])); | ||
} catch(e) { | ||
@@ -993,3 +993,3 @@ this.emit('unsyncable', e); | ||
delete this.signalFromClient[clientId]; | ||
self.clientCount--; | ||
this.clientCount--; | ||
}, | ||
@@ -996,0 +996,0 @@ |
{ | ||
"name": "canop", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Convergent algorithm for collaborative text.", | ||
@@ -5,0 +5,0 @@ "main": "canop.js", |
@@ -128,6 +128,6 @@ var canop = require('../canop.js'); | ||
// localId | ||
// id | ||
var star = new Star(''); | ||
assert.equal(star.clients[0].localId, 1, 'Client 0 localId'); | ||
assert.equal(star.clients[1].localId, 2, 'Client 1 localId'); | ||
assert.equal(star.clients[0].id, 1, 'Client 0 id'); | ||
assert.equal(star.clients[1].id, 2, 'Client 1 id'); | ||
@@ -140,1 +140,5 @@ // clientCount | ||
assert.equal(star.clients[1].clientCount, 2, 'Client 1 clientCount'); | ||
star.server.removeClient(star.clients[0]); | ||
sendChange(star, 1); | ||
assert.equal(star.server.clientCount, 1, 'Server clientCount after disconnection'); | ||
assert.equal(star.clients[1].clientCount, 1, 'Client 1 clientCount after disconnection'); |
196500
1464