simplify server

pull/1/head
ansuz 7 years ago
parent f96a5003b0
commit 5b84bc1a25

@ -10,13 +10,14 @@ try {
}
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: ""},
sockjs_echo = sockjs.createServer(sockjs_opts);
//urlParse = new RegExp("^/common/onlyoffice/doc/([0-9-.a-zA-Z_=]*)/c.+", 'i');
console.log("Start ooserver");
console.log("Port " + sockjs_echo.port);
console.log("Port " + port);
function getBaseUrl(protocol, hostHeader, forwardedProtoHeader, forwardedHostHeader) {
var url = '';
@ -64,24 +65,21 @@ module.exports.install = function(server, callbackFunction) {
try {
console.log("Received: " + 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.openCmd.format === "xlsx") {
fileUrl = origin + "oocell/test.bin";
} else if (data.openCmd.format === "pptx") {
fileUrl = origin + "ooslide/test.bin";
}
}
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}}});
break;
default:
break;
if (data.type !== 'auth') { return; }
console.log("Response auth");
var fileUrl = origin + "oodoc/test.bin";
if (data.openCmd) {
if (data.openCmd.format === "xlsx") {
fileUrl = origin + "oocell/test.bin";
} else if (data.openCmd.format === "pptx") {
fileUrl = origin + "ooslide/test.bin";
}
}
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) {
console.error(e);
//console.log("error receiving response: docId = %s type = %s\r\n%s", docId, (data && data.type) ? data.type : 'null', e.stack);

@ -251,7 +251,7 @@ app.use(function (req, res, next) {
var httpServer = httpsOpts ? Https.createServer(httpsOpts, app) : Http.createServer(app);
/* Install sockjs websocket server */
OOServer.install(httpServer, () => {
OOServer.install(httpServer, config.httpPort, () => {
httpServer.listen(config.httpPort,config.httpAddress,function(){
var host = config.httpAddress;
var hostName = !host.indexOf(':') ? '[' + host + ']' : host;
@ -264,7 +264,7 @@ OOServer.install(httpServer, () => {
});
if (config.httpSafePort) {
var safeHttpServer = Http.createServer(app).listen(config.httpSafePort, config.httpAddress);
OOServer.install(safeHttpServer, () => {
OOServer.install(safeHttpServer, config.httpSafePort, () => {
});
}

Loading…
Cancel
Save