|
|
@ -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,9 +65,10 @@ 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':
|
|
|
|
if (data.type !== 'auth') { return; }
|
|
|
|
console.log("Response auth");
|
|
|
|
console.log("Response auth");
|
|
|
|
|
|
|
|
|
|
|
|
var fileUrl = origin + "oodoc/test.bin";
|
|
|
|
var fileUrl = origin + "oodoc/test.bin";
|
|
|
|
|
|
|
|
|
|
|
|
if (data.openCmd) {
|
|
|
|
if (data.openCmd) {
|
|
|
@ -78,10 +80,6 @@ module.exports.install = function(server, callbackFunction) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sendData(conn, {"type":"auth","result":1,"sessionId":"08e77705-dc5c-477d-b73a-b1a7cbca1e9b","sessionTimeConnect":1494226099270,"participants":[]});
|
|
|
|
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}}});
|
|
|
|
sendData(conn, {"type":"documentOpen","data":{"type":"open","status":"ok","data":{"Editor.bin":fileUrl}}});
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} 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);
|
|
|
|