|
|
@ -10,13 +10,14 @@ try {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var origin = config.httpUnsafeOrigin || 'http://localhost:3000/';
|
|
|
|
var origin = config.httpUnsafeOrigin || 'http://localhost:3000/';
|
|
|
|
|
|
|
|
|
|
|
|
module.exports.install = function(server, callbackFunction) {
|
|
|
|
module.exports.install = function(server, port, callbackFunction) {
|
|
|
|
|
|
|
|
console.log();
|
|
|
|
var sockjs_opts = {sockjs_url: ""},
|
|
|
|
var sockjs_opts = {sockjs_url: ""},
|
|
|
|
sockjs_echo = sockjs.createServer(sockjs_opts);
|
|
|
|
sockjs_echo = sockjs.createServer(sockjs_opts);
|
|
|
|
//urlParse = new RegExp("^/common/onlyoffice/doc/([0-9-.a-zA-Z_=]*)/c.+", 'i');
|
|
|
|
//urlParse = new RegExp("^/common/onlyoffice/doc/([0-9-.a-zA-Z_=]*)/c.+", 'i');
|
|
|
|
|
|
|
|
|
|
|
|
console.log("Start ooserver");
|
|
|
|
console.log("Start ooserver");
|
|
|
|
console.log("Port " + sockjs_echo.port);
|
|
|
|
console.log("Port " + port);
|
|
|
|
|
|
|
|
|
|
|
|
function getBaseUrl(protocol, hostHeader, forwardedProtoHeader, forwardedHostHeader) {
|
|
|
|
function getBaseUrl(protocol, hostHeader, forwardedProtoHeader, forwardedHostHeader) {
|
|
|
|
var url = '';
|
|
|
|
var url = '';
|
|
|
@ -64,24 +65,21 @@ module.exports.install = function(server, callbackFunction) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
console.log("Received: " + message);
|
|
|
|
console.log("Received: " + message);
|
|
|
|
data = JSON.parse(message);
|
|
|
|
data = JSON.parse(message);
|
|
|
|
switch (data.type) {
|
|
|
|
|
|
|
|
case 'auth':
|
|
|
|
|
|
|
|
console.log("Response auth");
|
|
|
|
|
|
|
|
var fileUrl = origin + "oodoc/test.bin";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (data.openCmd) {
|
|
|
|
if (data.type !== 'auth') { return; }
|
|
|
|
if (data.openCmd.format === "xlsx") {
|
|
|
|
console.log("Response auth");
|
|
|
|
fileUrl = origin + "oocell/test.bin";
|
|
|
|
|
|
|
|
} else if (data.openCmd.format === "pptx") {
|
|
|
|
var fileUrl = origin + "oodoc/test.bin";
|
|
|
|
fileUrl = origin + "ooslide/test.bin";
|
|
|
|
|
|
|
|
}
|
|
|
|
if (data.openCmd) {
|
|
|
|
}
|
|
|
|
if (data.openCmd.format === "xlsx") {
|
|
|
|
sendData(conn, {"type":"auth","result":1,"sessionId":"08e77705-dc5c-477d-b73a-b1a7cbca1e9b","sessionTimeConnect":1494226099270,"participants":[]});
|
|
|
|
fileUrl = origin + "oocell/test.bin";
|
|
|
|
sendData(conn, {"type":"documentOpen","data":{"type":"open","status":"ok","data":{"Editor.bin":fileUrl}}});
|
|
|
|
} else if (data.openCmd.format === "pptx") {
|
|
|
|
break;
|
|
|
|
fileUrl = origin + "ooslide/test.bin";
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sendData(conn, {"type":"auth","result":1,"sessionId":"08e77705-dc5c-477d-b73a-b1a7cbca1e9b","sessionTimeConnect":1494226099270,"participants":[]});
|
|
|
|
|
|
|
|
sendData(conn, {"type":"documentOpen","data":{"type":"open","status":"ok","data":{"Editor.bin":fileUrl}}});
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e);
|
|
|
|
console.error(e);
|
|
|
|
//console.log("error receiving response: docId = %s type = %s\r\n%s", docId, (data && data.type) ? data.type : 'null', e.stack);
|
|
|
|
//console.log("error receiving response: docId = %s type = %s\r\n%s", docId, (data && data.type) ? data.type : 'null', e.stack);
|
|
|
|