First step for realtime in onlyoffice apps
This commit is contained in:
@@ -15,6 +15,7 @@ define([
|
||||
'/common/onlyoffice/oocell_base.js',
|
||||
'/common/onlyoffice/oodoc_base.js',
|
||||
'/common/onlyoffice/ooslide_base.js',
|
||||
'/common/outer/worker-channel.js',
|
||||
|
||||
'/bower_components/tweetnacl/nacl-fast.min.js',
|
||||
'/bower_components/file-saver/FileSaver.min.js',
|
||||
@@ -38,7 +39,8 @@ define([
|
||||
FileCrypto,
|
||||
EmptyCell,
|
||||
EmptyDoc,
|
||||
EmptySlide)
|
||||
EmptySlide,
|
||||
Channel)
|
||||
{
|
||||
var saveAs = window.saveAs;
|
||||
var Nacl = window.nacl;
|
||||
@@ -83,6 +85,35 @@ define([
|
||||
return file;
|
||||
};
|
||||
|
||||
var openRtChannel = function (data) {
|
||||
// XXX
|
||||
var channel = Hash.createChannelId();
|
||||
ctx.sframeChan.query('Q_OO_OPENCHANNEL', channel, function (err, obj) {
|
||||
if (err || (obj && obj.error)) { console.error(err || (obj && obj.error)); }
|
||||
});
|
||||
};
|
||||
|
||||
var mkChannel = function () {
|
||||
var msgEv = Util.mkEvent();
|
||||
var iframe = $('#cp-app-oo-container > iframe')[0].contentWindow;
|
||||
window.addEventListener('message', function (msg) {
|
||||
if (msg.source !== iframe) { return; }
|
||||
msgEv.fire(msg);
|
||||
});
|
||||
var postMsg = function (data) {
|
||||
iframe.postMessage(data, '*');
|
||||
};
|
||||
Channel.create(msgEv, postMsg, function (chan) {
|
||||
APP.chan = chan;
|
||||
chan.on('CMDFROMOO', function (data) {
|
||||
console.log('command from oo', data);
|
||||
setTimeout(function () {
|
||||
chan.event('RTMSG', 'Pewpewpew');
|
||||
}, 2000);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
var startOO = function (blob, file) {
|
||||
if (APP.ooconfig) { return void console.error('already started'); }
|
||||
var url = URL.createObjectURL(blob);
|
||||
@@ -144,6 +175,7 @@ define([
|
||||
if (ifr) { ifr.remove(); }
|
||||
};
|
||||
APP.docEditor = new DocsAPI.DocEditor("cp-app-oo-placeholder", APP.ooconfig);
|
||||
mkChannel();
|
||||
};
|
||||
|
||||
var getContent = APP.getContent = function () {
|
||||
|
||||
@@ -53,6 +53,21 @@ define([
|
||||
Cryptpad.setPadAttribute('lastVersion', data.url, cb);
|
||||
});
|
||||
});
|
||||
sframeChan.on('Q_OO_OPENCHANNEL', function (data, cb) {
|
||||
Cryptpad.onlyoffice.execCommand({
|
||||
cmd: 'OPEN_CHANNEL',
|
||||
data: {
|
||||
channel: data,
|
||||
secret: secret
|
||||
}
|
||||
}, cb);
|
||||
});
|
||||
sframeChan.on('Q_OO_COMMAND', function (data, cb) {
|
||||
Cryptpad.onlyoffice.execCommand(data, cb);
|
||||
});
|
||||
Cryptpad.onlyoffice.onEvent.reg(function (data) {
|
||||
sframeChan.event('EV_OO_EVENT', data);
|
||||
});
|
||||
};
|
||||
SFCommonO.start({
|
||||
type: 'oo',
|
||||
|
||||
66
www/common/onlyoffice/sdkjs/cell/sdk-all-min.js
vendored
66
www/common/onlyoffice/sdkjs/cell/sdk-all-min.js
vendored
@@ -3770,6 +3770,50 @@ AscBrowser.convertToRetinaValue = function(value, isScale)
|
||||
sockjs = this.sockjs = {};
|
||||
//t._state = true;
|
||||
|
||||
var send = function (data) {
|
||||
setTimeout(function () {
|
||||
console.log(data);
|
||||
sockjs.onmessage({
|
||||
data: JSON.stringify(data)
|
||||
});
|
||||
});
|
||||
};
|
||||
var license = {
|
||||
type: 'license',
|
||||
license: {
|
||||
type: 3,
|
||||
light: false,
|
||||
trial: false,
|
||||
rights: 1,
|
||||
buildVersion: "4.3.3",
|
||||
buildNumber: 4,
|
||||
branding: false
|
||||
}
|
||||
};
|
||||
var channel;
|
||||
|
||||
require([
|
||||
'/common/outer/worker-channel.js',
|
||||
'/common/common-util.js'
|
||||
], function (Channel, Util) {
|
||||
var msgEv = Util.mkEvent();
|
||||
var p = window.parent;
|
||||
window.addEventListener('message', function (msg) {
|
||||
if (msg.source !== p) { return; }
|
||||
msgEv.fire(msg);
|
||||
});
|
||||
var postMsg = function (data) {
|
||||
p.postMessage(data, '*');
|
||||
};
|
||||
Channel.create(msgEv, postMsg, function (chan) {
|
||||
channel = chan;
|
||||
send(license);
|
||||
chan.on('RTMSG', function (data) {
|
||||
console.log('receiving RTMSG', data);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
sockjs.onopen = function() {
|
||||
/*
|
||||
if (t.reconnectTimeout) {
|
||||
@@ -3861,14 +3905,6 @@ AscBrowser.convertToRetinaValue = function(value, isScale)
|
||||
console.error('Close realtime');
|
||||
};
|
||||
|
||||
var send = function (data) {
|
||||
setTimeout(function () {
|
||||
console.log(data);
|
||||
sockjs.onmessage({
|
||||
data: JSON.stringify(data)
|
||||
});
|
||||
});
|
||||
};
|
||||
sockjs.send = function (data) {
|
||||
console.log(data);
|
||||
try {
|
||||
@@ -3893,6 +3929,7 @@ AscBrowser.convertToRetinaValue = function(value, isScale)
|
||||
};
|
||||
send(msg);
|
||||
send(msg2);
|
||||
channel.event('CMDFROMOO', 'Hey');
|
||||
break;
|
||||
case 'getMessages':
|
||||
msg = {};
|
||||
@@ -3900,19 +3937,6 @@ AscBrowser.convertToRetinaValue = function(value, isScale)
|
||||
}
|
||||
};
|
||||
|
||||
var license = {
|
||||
type: 'license',
|
||||
license: {
|
||||
type: 3,
|
||||
light: false,
|
||||
trial: false,
|
||||
rights: 1,
|
||||
buildVersion: "4.3.3",
|
||||
buildNumber: 4,
|
||||
branding: false
|
||||
}
|
||||
};
|
||||
send(license);
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user