mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-24 16:23:12 +09:00
Add name to account model
Add the name of the account that's connected to the control link on the web interface via an additional property on the ready payload for the control link.
This commit is contained in:
1 parent
e1549c1b0c
commit
6458810571
6 files changed
+50
-5
No files matched your search
@@ -1371,8 +1371,10 @@ class WebSocketServerConnector extends libLink.WebSocketBaseConnector {
|
||||
*
|
||||
* @param {string} sessionToken -
|
||||
* the session token to send to the client.
|
||||
* @param {Object=} additionalData -
|
||||
* extra properties to send along the ready message.
|
||||
*/
|
||||
ready(sessionToken) {
|
||||
ready(sessionToken, additionalData) {
|
||||
this._heartbeatInterval = masterConfig.get("master.heartbeat_interval");
|
||||
this._socket.send(JSON.stringify({
|
||||
seq: null,
|
||||
@@ -1380,6 +1382,7 @@ class WebSocketServerConnector extends libLink.WebSocketBaseConnector {
|
||||
data: {
|
||||
session_token: sessionToken,
|
||||
heartbeat_interval: this._heartbeatInterval,
|
||||
...additionalData,
|
||||
},
|
||||
}));
|
||||
|
||||
@@ -1650,6 +1653,7 @@ async function handleHandshake(message, socket, req, attachHandler) {
|
||||
let connector = new WebSocketServerConnector(socket, sessionId);
|
||||
activeConnectors.set(sessionId, connector);
|
||||
|
||||
let additionalReadyData = {};
|
||||
if (type === "register_slave") {
|
||||
let connection = slaveConnections.get(data.id);
|
||||
if (connection) {
|
||||
@@ -1664,9 +1668,12 @@ async function handleHandshake(message, socket, req, attachHandler) {
|
||||
} else if (type === "register_control") {
|
||||
logger.verbose(`SOCKET | registered control from ${req.socket.remoteAddress}`);
|
||||
controlConnections.push(new ControlConnection(data, connector, user));
|
||||
additionalReadyData["account"] = {
|
||||
name: user.name,
|
||||
};
|
||||
}
|
||||
|
||||
connector.ready(sessionToken);
|
||||
connector.ready(sessionToken, additionalReadyData);
|
||||
}
|
||||
|
||||
wss.on("connection", (socket, req) => {
|
||||
|
||||
Reference in new issue
Block a user