Skip to content

Commit

Permalink
Merge branch 'main' of github.com:rustymotors/probable-spoon
Browse files Browse the repository at this point in the history
  • Loading branch information
drazisil committed Jun 1, 2024
2 parents 768d76e + 923ec5c commit 613f249
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 39 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# probable-spoon
# obsidian

[![Node.js CI](https://github.com/rustymotors/probable-spoon/actions/workflows/node.js.yml/badge.svg)](https://github.com/rustymotors/probable-spoon/actions/workflows/node.js.yml)
[![Node.js CI](https://github.com/rustymotors/obsidian/actions/workflows/node.js.yml/badge.svg)](https://github.com/rustymotors/obsidian/actions/workflows/node.js.yml)
65 changes: 34 additions & 31 deletions packages/main/src/ShardService.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/** @type {Map<number, import("obsidian-main").IShardEntry>} */
const shards = new Map();

Expand Down Expand Up @@ -56,8 +55,8 @@ class ShardEntry {
}

/**
*
* @param {number} population
*
* @param {number} population
*/
setPopulation(population) {
this.population = population;
Expand All @@ -67,45 +66,49 @@ class ShardEntry {
* @returns {string}
*/
formatForWeb() {
return `[${this.name}]\n`
+ `\tDescription=${this.id}\n`
+ `\tShardId=${this.id}\n`
+ `\tLoginServerIP=${this.loginServerIP}\n`
+ `\tLoginServerPort=${this.loginServerPort}\n`
+ `\tLobbyServerIP=${this.lobbyServerIP}\n`
+ `\tLobbyServerPort=${this.lobbyServerPort}\n`
+ `\tMCOTSServerIP=${this.mcotsServerIP}\n`
+ `\tStatusId=${this.statusId}\n`
+ `\tStatus_Reason=${this.statusReason}\n`
+ `\tServerGroup_Name=${this.serverGroupName}\n`
+ `\tPopulation=${this.population}\n`
+ `\tMaxPersonasPerUser=${this.maxPersonasPerUser}\n`
+ `\tDiagnosticServerHost=${this.diagServerIP}\n`
+ `\tDiagnosticServerPort=${this.diagServerPort}\n`;
return (
`[${this.name}]\n` +
`\tDescription=${this.id}\n` +
`\tShardId=${this.id}\n` +
`\tLoginServerIP=${this.loginServerIP}\n` +
`\tLoginServerPort=${this.loginServerPort}\n` +
`\tLobbyServerIP=${this.lobbyServerIP}\n` +
`\tLobbyServerPort=${this.lobbyServerPort}\n` +
`\tMCOTSServerIP=${this.mcotsServerIP}\n` +
`\tStatusId=${this.statusId}\n` +
`\tStatus_Reason=${this.statusReason}\n` +
`\tServerGroup_Name=${this.serverGroupName}\n` +
`\tPopulation=${this.population}\n` +
`\tMaxPersonasPerUser=${this.maxPersonasPerUser}\n` +
`\tDiagnosticServerHost=${this.diagServerIP}\n` +
`\tDiagnosticServerPort=${this.diagServerPort}\n`
);
}
}

export class ShardService {

/**
*
* @param {number} id
* @param {string} name
*
* @param {number} id
* @param {string} name
* @param {string} description
* @param {string} ip
* @param {string} serverGroupName
*/
addShard(id, name, description, ip, serverGroupName) {
shards.set(id, new ShardEntry({
shards.set(
id,
name,
description,
loginServerIP: ip,
lobbyServerIP: ip,
serverGroupName: serverGroupName,
mcotsServerIP: ip,
diagServerIP: ip,
}));
new ShardEntry({
id,
name,
description,
loginServerIP: ip,
lobbyServerIP: ip,
serverGroupName: serverGroupName,
mcotsServerIP: ip,
diagServerIP: ip,
}),
);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/UserLoginService.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class UserLoginService {
*/
checkUser(username, password) {
const user = users.find(
(user) => user.username === username && user.password === password
(user) => user.username === username && user.password === password,
);

return user ? user.customerId : -1;
Expand Down
8 changes: 4 additions & 4 deletions packages/main/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ export default function main() {
8226,
onSocketListening,
(socket) => onSocketConnection(socket, onNPSData),
onServerError
onServerError,
);
personaServer = new TCPServer(
8228,
onSocketListening,
(socket) => onSocketConnection(socket, onNPSData),
onServerError
onServerError,
);

const shardService = new ShardService();
Expand All @@ -146,11 +146,11 @@ export default function main() {
mainLoop.addTask("stop", loginServer.close.bind(loginServer, onServerError));
mainLoop.addTask(
"stop",
personaServer.close.bind(personaServer, onServerError)
personaServer.close.bind(personaServer, onServerError),
);
mainLoop.addTask(
"stop",
userLoginService.deleteAllTokens.bind(userLoginService)
userLoginService.deleteAllTokens.bind(userLoginService),
);

mainLoop.start();
Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/web.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function sendError(res, statusCode, message) {
res.statusCode = statusCode;
res.setHeader("Content-Type", "text/plain");
res.end(
`reasoncode=INV-200\nreasontext=${message}\nreasonurl=https://rusty-motors.com`
`reasoncode=INV-200\nreasontext=${message}\nreasonurl=https://rusty-motors.com`,
);
}

Expand Down

0 comments on commit 613f249

Please sign in to comment.