Fix duplicate text bug on reconnect or ACK timeout
This commit is contained in:
@@ -879,7 +879,8 @@ define([
|
|||||||
postMessage("LEAVE_PAD", data, cb);
|
postMessage("LEAVE_PAD", data, cb);
|
||||||
};
|
};
|
||||||
pad.sendPadMsg = function (data, cb) {
|
pad.sendPadMsg = function (data, cb) {
|
||||||
postMessage("SEND_PAD_MSG", data, cb);
|
// -1 ==> no timeout, we may receive the callback only when we reconnect
|
||||||
|
postMessage("SEND_PAD_MSG", data, cb, { timeout: -1 });
|
||||||
};
|
};
|
||||||
pad.onReadyEvent = Util.mkEvent();
|
pad.onReadyEvent = Util.mkEvent();
|
||||||
pad.onMessageEvent = Util.mkEvent();
|
pad.onMessageEvent = Util.mkEvent();
|
||||||
|
|||||||
@@ -45,10 +45,13 @@ define([
|
|||||||
var txid = mkTxid();
|
var txid = mkTxid();
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
var to = opts.timeout || 30000;
|
var to = opts.timeout || 30000;
|
||||||
var timeout = setTimeout(function () {
|
var timeout;
|
||||||
delete queries[txid];
|
if (to > 0) {
|
||||||
cb('TIMEOUT');
|
timeout = setTimeout(function () {
|
||||||
}, to);
|
delete queries[txid];
|
||||||
|
cb('TIMEOUT');
|
||||||
|
}, to);
|
||||||
|
}
|
||||||
acks[txid] = function (err) {
|
acks[txid] = function (err) {
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
delete acks[txid];
|
delete acks[txid];
|
||||||
|
|||||||
@@ -59,10 +59,11 @@ define([
|
|||||||
logLevel: logLevel
|
logLevel: logLevel
|
||||||
});
|
});
|
||||||
chainpad.onMessage(function(message, cb) {
|
chainpad.onMessage(function(message, cb) {
|
||||||
|
// -1 ==> no timeout, we may receive the callback only when we reconnect
|
||||||
sframeChan.query('Q_RT_MESSAGE', message, function (err) {
|
sframeChan.query('Q_RT_MESSAGE', message, function (err) {
|
||||||
if (!err) { evPatchSent.fire(); }
|
if (!err) { evPatchSent.fire(); }
|
||||||
cb(err);
|
cb(err);
|
||||||
});
|
}, { timeout: -1 });
|
||||||
});
|
});
|
||||||
chainpad.onPatch(function () {
|
chainpad.onPatch(function () {
|
||||||
onRemote({ realtime: chainpad });
|
onRemote({ realtime: chainpad });
|
||||||
|
|||||||
Reference in New Issue
Block a user