Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#369 Refresh Vector Layers #370

Merged
merged 1 commit into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions API/Backend/Config/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ let setup = {
process.env.NODE_ENV === "development"
? ""
: process.env.ROOT_PATH || "",
WEBSOCKET_ROOT_PATH:
process.env.NODE_ENV === "development"
? ""
: process.env.WEBSOCKET_ROOT_PATH || "",
});
}
);
Expand Down
104 changes: 45 additions & 59 deletions API/websocket.js
Original file line number Diff line number Diff line change
@@ -1,66 +1,52 @@
const WebSocket = require('isomorphic-ws');
const WebSocket = require("isomorphic-ws");
const logger = require("./logger");

const websocket = {
wss: null,
init: function (server) {
logger(
"info",
"Trying to init websocket...",
"websocket",
null,
""
);

if (!server === null) {
logger(
"websocket_error",
"server parameter not defined.",
"error",
null,
""
);
return null
}

logger(
"info",
"Server is valid so still trying to init websocket...",
"websocket",
null,
""
);

const wss = new WebSocket.Server({ server });
websocket.wss = wss;

// Broadcast to all clients
wss.broadcast = function broadcast(data, isBinary) {
wss.clients.forEach(client => {
if (client.readyState === WebSocket.OPEN && data !== undefined) {
client.send(data, { binary: isBinary });
}
});
};

wss.on('connection', (ws) => {
ws.on('message', (message) => {
wss.broadcast(message);
});
});

wss.on('close', () => {
logger(
"info",
"Websocket disconnected...",
"websocket",
null,
""
);
websocket.wss = null
});
wss: null,
init: function (server) {
logger("info", "Trying to init websocket...", "websocket", null, "");

if (!server === null) {
logger(
"websocket_error",
"server parameter not defined.",
"error",
null,
""
);
return null;
}
}

logger(
"info",
"Server is valid so still trying to init websocket...",
"websocket",
null,
""
);
const wss = new WebSocket.Server({ server });
websocket.wss = wss;

// Broadcast to all clients
wss.broadcast = function broadcast(data, isBinary) {
wss.clients.forEach((client) => {
if (client.readyState === WebSocket.OPEN && data !== undefined) {
client.send(data, { binary: isBinary });
}
});
};

wss.on("connection", (ws) => {
ws.on("message", (message) => {
wss.broadcast(message);
});
});

wss.on("close", () => {
logger("info", "Websocket disconnected...", "websocket", null, "");
websocket.wss = null;
});
},
};

module.exports = { websocket };
4 changes: 4 additions & 0 deletions configuration/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ function getClientEnvironment(publicUrl) {
(process.env.NODE_ENV || "development") === "development"
? ""
: process.env.ROOT_PATH || "",
WEBSOCKET_ROOT_PATH:
(process.env.NODE_ENV || "development") === "development"
? ""
: process.env.WEBSOCKET_ROOT_PATH || "",
// We support configuring the sockjs pathname during development.
// These settings let a developer run multiple simultaneous projects.
// They are used as the connection `hostname`, `pathname` and `port`
Expand Down
4 changes: 4 additions & 0 deletions docs/pages/Setup/ENVs/ENVs.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ Sets "SameSite=None; Secure" on the login cookie. Useful when using AUTH=local a

Set MMGIS to be deployed under a subpath. For example if serving at the subpath 'https://{domain}/path/where/I/serve/mmgis' is desired, set `ROOT_PATH=/path/where/I/serve/mmgis`. If no subpath, leave blank. | string | default `""`

#### `WEBSOCKET_ROOT_PATH=`

Overrides ROOT_PATH's use when the client connects via websocket. Websocket url: `${ws_protocol}://${window.location.host}${WEBSOCKET_ROOT_PATH || ROOT_PATH || ''}/` | string | default `""`

#### `CLEARANCE_NUMBER=`

Sets a clearance for the website | string | default `CL##-####`
Expand Down
Loading