Merge branch 'duplicateText2' into staging

This commit is contained in:
yflory 2020-03-26 16:23:12 +01:00
commit c7688b7c8c
4 changed files with 17 additions and 8 deletions

View file

@ -879,7 +879,8 @@ define([
postMessage("LEAVE_PAD", 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.onMessageEvent = Util.mkEvent();

View file

@ -1596,7 +1596,10 @@ define([
onConnect: function (wc, sendMessage) {
channel.sendMessage = function (msg, cId, cb) {
// Send to server
sendMessage(msg, function () {
sendMessage(msg, function (err) {
if (err) {
return void cb({ error: err });
}
// Broadcast to other tabs
channel.pushHistory(CpNetflux.removeCp(msg), /^cp\|/.test(msg));
channel.bcast("PAD_MESSAGE", {

View file

@ -45,10 +45,13 @@ define([
var txid = mkTxid();
opts = opts || {};
var to = opts.timeout || 30000;
var timeout = setTimeout(function () {
delete queries[txid];
cb('TIMEOUT');
}, to);
var timeout;
if (to > 0) {
timeout = setTimeout(function () {
delete queries[txid];
cb('TIMEOUT');
}, to);
}
acks[txid] = function (err) {
clearTimeout(timeout);
delete acks[txid];

View file

@ -61,10 +61,12 @@ define([
logLevel: logLevel
});
_chainpad.onMessage(function(message, cb) {
sframeChan.query('Q_RT_MESSAGE', message, function (err) {
// -1 ==> no timeout, we may receive the callback only when we reconnect
sframeChan.query('Q_RT_MESSAGE', message, function (_err, obj) {
var err = _err || (obj && obj.error);
if (!err) { evPatchSent.fire(); }
cb(err);
});
}, { timeout: -1 });
});
_chainpad.onPatch(function () {
onRemote({ realtime: chainpad });