Codefactor refactor

This commit is contained in:
tgpethan 2021-02-12 23:36:35 +00:00
parent 69de312cf0
commit cde3a90922
7 changed files with 29 additions and 25 deletions

View file

@ -1,5 +1,7 @@
# Binato
An implementation of osu!bancho in Javascript
[![CodeFactor](https://www.codefactor.io/repository/github/tgpethan/binato/badge/master)](https://www.codefactor.io/repository/github/tgpethan/binato/overview/master)
<hr>
### Features:

View file

@ -1,5 +1,4 @@
const osu = require("osu-packet"),
getUserById = require("./util/getUserById.js"),
UserPresenceBundle = require("./Packets/UserPresenceBundle.js"),
UserPresence = require("./Packets/UserPresence.js"),
StatusUpdate = require("./Packets/StatusUpdate.js"),

View file

@ -137,7 +137,9 @@ module.exports = class {
MatchUser.addActionToQueue(osuPacketWriter.toBuffer);
return this;
} catch (e) { }
} catch (e) {
console.error(e);
}
}
updateMatch(MatchData) {

View file

@ -41,10 +41,13 @@ module.exports = class {
}
sendToStream(streamName, streamData, initUser = null) {
// Make sure the stream we are attempting to send to even exists
if (!this.doesStreamExist(streamName))
return global.consoleHelper.printBancho(`Did not send to stream [${streamName}] because it does not exist!`);
// Get the stream to send the data to
const currentStream = this.avaliableStreams[streamName];
try {
// Loop through the users in this stream
for (let i = 0; i < currentStream.streamUsers.length; i++) {
// Get the user token of the user in the queue
@ -61,7 +64,6 @@ module.exports = class {
// Send stream data to user's own queue
currentUser.addActionToQueue(streamData);
}
} catch (e) {}
}
addUserToStream(streamName, userToken) {

View file

@ -141,7 +141,7 @@ module.exports = function(req, res, loginInfo) {
// Complete login
res.writeHead(200, {
"cho-token": NewUser.uuid,
"cho-protocol": 19,
"cho-protocol": global.protocolVersion,
"Connection": "keep-alive",
"Keep-Alive": "timeout=5, max=100",
"Content-Type": "text/html; charset=UTF-8"

View file

@ -27,7 +27,7 @@ function incorrectLoginResponse() {
osuPacketWriter.toBuffer,
{
'cho-token': 'No',
'cho-protocol': 19,
'cho-protocol': global.protocolVersion,
'Connection': 'keep-alive',
'Keep-Alive': 'timeout=5, max=100',
'Content-Type': 'text/html; charset=UTF-8'

View file

@ -84,7 +84,7 @@ setInterval(() => {
fs.appendFile(
"server-stats.log",
`${global.usersOnline}|${global.multiplayerMatches[0]},${global.multiplayerMatches[1]}|${global.httpRequestsPerLogInterval}|${new Date().getTime()}@`,
() => { }
() => {}
);
global.httpRequestsPerLogInterval = 0;
@ -94,7 +94,7 @@ if (!fs.existsSync("tHMM.ds")) fs.writeFileSync("tHMM.ds", "0");
global.totalHistoricalMultiplayerMatches = parseInt(fs.readFileSync("tHMM.ds").toString());
global.getAndAddToHistoricalMultiplayerMatches = function() {
global.totalHistoricalMultiplayerMatches++;
fs.writeFile("tHMM.ds", global.totalHistoricalMultiplayerMatches, (e) => {});
fs.writeFile("tHMM.ds", global.totalHistoricalMultiplayerMatches, () => {});
return global.totalHistoricalMultiplayerMatches;
}
@ -129,8 +129,7 @@ module.exports = function(req, res) {
requestData = req.packet;
// Server's response & new client token
let responseTokenString = "",
responseData = new Buffer.alloc(0);
let responseData = new Buffer.alloc(0);
// Check if the user is logged in
if (requestTokenString == null) {
@ -341,7 +340,7 @@ module.exports = function(req, res) {
} finally {
// Send the prepared packet to the client
res.writeHead(200, {
"cho-protocol": 19,
"cho-protocol": global.protocolVersion,
"Connection": "keep-alive",
"Keep-Alive": "timeout=5, max=100",
"Content-Type": "text/html; charset=UTF-8"