josephg/ShareJS — Issue #73: Doc.Close(), closes all the future sharejs.open() calls.
Author: Nathanaela
Created: 2012-02-24 04:21:29+00:00
State: open

If you write:

sharejs.open("blah","text", function(err, doc)) {
// This connection works, and we can do what we need to.. Then later when deleting the control we use
doc.close();
}

sharejs.open("adifferentblah","text", function(err, doc)) {
if (err) { console.log(err); }
}

You will get a error about the connection being closed. And no futher connections are available.

Since I haven't had time to work in coffeescript, I'll tell you have I fixed the client side share.js file... :)

I worked around this by moving everything in the "Connection" function to a new function prototype called "reopen(host)" and then just calling reopen(host) as the only call in the main constructor.

Then I added these four lines (to reset the entire state to the reopen function:
this.lastError = undefined;
this.id = undefined;
this.lastReceivedDoc = undefined;
this.lastSentDoc = undefined;
and then in the Connection.Open I changed the 'stopped' error to
if (this.state === 'stopped') {
this.reOpen(this.host);
}