General BanchoServer cleanup

This commit is contained in:
Holly Stubbs 2023-09-10 18:31:29 +01:00
parent 0d68b07e9c
commit 09dc1ffb76
Signed by: tgpholly
GPG key ID: B8583C4B7D18119E
2 changed files with 50 additions and 48 deletions

View file

@ -114,7 +114,7 @@ export default async function HandleRequest(req:IncomingMessage, res:ServerRespo
switch (CurrentPacket.id) { switch (CurrentPacket.id) {
case Packets.Client_ChangeAction: case Packets.Client_ChangeAction:
ChangeAction(PacketUser, CurrentPacket.data); ChangeAction(PacketUser, CurrentPacket.data);
break; break;
case Packets.Client_SendPublicMessage: case Packets.Client_SendPublicMessage:
const message:MessageData = CurrentPacket.data; const message:MessageData = CurrentPacket.data;
@ -122,167 +122,171 @@ export default async function HandleRequest(req:IncomingMessage, res:ServerRespo
if (channel instanceof Channel) { if (channel instanceof Channel) {
channel.SendMessage(PacketUser, CurrentPacket.data.message); channel.SendMessage(PacketUser, CurrentPacket.data.message);
} }
break; break;
case Packets.Client_Logout: case Packets.Client_Logout:
await Logout(PacketUser); await Logout(PacketUser);
break; break;
case Packets.Client_RequestStatusUpdate: case Packets.Client_RequestStatusUpdate:
UserPresenceBundle(PacketUser); UserPresenceBundle(PacketUser);
break; break;
case Packets.Client_StartSpectating: case Packets.Client_StartSpectating:
spectatorManager.startSpectating(PacketUser, CurrentPacket.data); spectatorManager.startSpectating(PacketUser, CurrentPacket.data);
break; break;
case Packets.Client_SpectateFrames: case Packets.Client_SpectateFrames:
spectatorManager.spectatorFrames(PacketUser, CurrentPacket.data); spectatorManager.spectatorFrames(PacketUser, CurrentPacket.data);
break; break;
case Packets.Client_StopSpectating: case Packets.Client_StopSpectating:
spectatorManager.stopSpectating(PacketUser); spectatorManager.stopSpectating(PacketUser);
break; break;
case Packets.Client_SendPrivateMessage: case Packets.Client_SendPrivateMessage:
PrivateMessage(PacketUser, CurrentPacket.data); PrivateMessage(PacketUser, CurrentPacket.data);
break; break;
case Packets.Client_JoinLobby: case Packets.Client_JoinLobby:
shared.multiplayerManager.JoinLobby(PacketUser); shared.multiplayerManager.JoinLobby(PacketUser);
break; break;
case Packets.Client_PartLobby: case Packets.Client_PartLobby:
shared.multiplayerManager.LeaveLobby(PacketUser); shared.multiplayerManager.LeaveLobby(PacketUser);
break; break;
case Packets.Client_CreateMatch: case Packets.Client_CreateMatch:
await shared.multiplayerManager.CreateMatch(PacketUser, CurrentPacket.data); await shared.multiplayerManager.CreateMatch(PacketUser, CurrentPacket.data);
break; break;
case Packets.Client_JoinMatch: case Packets.Client_JoinMatch:
shared.multiplayerManager.JoinMatch(PacketUser, CurrentPacket.data); shared.multiplayerManager.JoinMatch(PacketUser, CurrentPacket.data);
break; break;
case Packets.Client_MatchChangeSlot: case Packets.Client_MatchChangeSlot:
PacketUser.match?.moveToSlot(PacketUser, CurrentPacket.data); PacketUser.match?.moveToSlot(PacketUser, CurrentPacket.data);
break; break;
case Packets.Client_MatchReady: case Packets.Client_MatchReady:
PacketUser.match?.setStateReady(PacketUser); PacketUser.match?.setStateReady(PacketUser);
break; break;
case Packets.Client_MatchChangeSettings: case Packets.Client_MatchChangeSettings:
await PacketUser.match?.updateMatch(PacketUser, CurrentPacket.data); await PacketUser.match?.updateMatch(PacketUser, CurrentPacket.data);
break; break;
case Packets.Client_MatchNotReady: case Packets.Client_MatchNotReady:
PacketUser.match?.setStateNotReady(PacketUser); PacketUser.match?.setStateNotReady(PacketUser);
break; break;
// TODO: Match leave so the matches actually close
case Packets.Client_PartMatch: case Packets.Client_PartMatch:
await PacketUser.match?.leaveMatch(PacketUser); await PacketUser.match?.leaveMatch(PacketUser);
break; break;
case Packets.Client_MatchLock: case Packets.Client_MatchLock:
PacketUser.match?.lockOrKick(PacketUser, CurrentPacket.data); PacketUser.match?.lockOrKick(PacketUser, CurrentPacket.data);
break; break;
case Packets.Client_MatchNoBeatmap: case Packets.Client_MatchNoBeatmap:
PacketUser.match?.missingBeatmap(PacketUser); PacketUser.match?.missingBeatmap(PacketUser);
break; break;
case Packets.Client_MatchSkipRequest: case Packets.Client_MatchSkipRequest:
PacketUser.match?.matchSkip(PacketUser); PacketUser.match?.matchSkip(PacketUser);
break; break;
case Packets.Client_MatchHasBeatmap: case Packets.Client_MatchHasBeatmap:
PacketUser.match?.notMissingBeatmap(PacketUser); PacketUser.match?.notMissingBeatmap(PacketUser);
break; break;
case Packets.Client_MatchTransferHost: case Packets.Client_MatchTransferHost:
PacketUser.match?.transferHost(PacketUser, CurrentPacket.data); PacketUser.match?.transferHost(PacketUser, CurrentPacket.data);
break; break;
case Packets.Client_MatchChangeMods: case Packets.Client_MatchChangeMods:
PacketUser.match?.updateMods(PacketUser, CurrentPacket.data); PacketUser.match?.updateMods(PacketUser, CurrentPacket.data);
break; break;
case Packets.Client_MatchStart: case Packets.Client_MatchStart:
PacketUser.match?.startMatch(); PacketUser.match?.startMatch();
break; break;
case Packets.Client_MatchLoadComplete: case Packets.Client_MatchLoadComplete:
PacketUser.match?.matchPlayerLoaded(PacketUser); PacketUser.match?.matchPlayerLoaded(PacketUser);
break; break;
case Packets.Client_MatchComplete: case Packets.Client_MatchComplete:
await PacketUser.match?.onPlayerFinishMatch(PacketUser); await PacketUser.match?.onPlayerFinishMatch(PacketUser);
break; break;
case Packets.Client_MatchScoreUpdate: case Packets.Client_MatchScoreUpdate:
PacketUser.match?.updatePlayerScore(PacketUser, CurrentPacket.data); PacketUser.match?.updatePlayerScore(PacketUser, CurrentPacket.data);
break; break;
case Packets.Client_MatchFailed: case Packets.Client_MatchFailed:
PacketUser.match?.matchFailed(PacketUser); PacketUser.match?.matchFailed(PacketUser);
break; break;
case Packets.Client_MatchChangeTeam: case Packets.Client_MatchChangeTeam:
PacketUser.match?.changeTeam(PacketUser); PacketUser.match?.changeTeam(PacketUser);
break; break;
case Packets.Client_ChannelJoin: case Packets.Client_ChannelJoin:
//ChannelJoin(PacketUser, CurrentPacket.data); //ChannelJoin(PacketUser, CurrentPacket.data);
break; break;
case Packets.Client_ChannelPart: case Packets.Client_ChannelPart:
//ChannelPart(PacketUser, CurrentPacket.data); //ChannelPart(PacketUser, CurrentPacket.data);
break; break;
case Packets.Client_SetAwayMessage: case Packets.Client_SetAwayMessage:
//SetAwayMessage(PacketUser, CurrentPacket.data); //SetAwayMessage(PacketUser, CurrentPacket.data);
break; break;
case Packets.Client_FriendAdd: case Packets.Client_FriendAdd:
AddFriend(PacketUser, CurrentPacket.data); AddFriend(PacketUser, CurrentPacket.data);
break; break;
case Packets.Client_FriendRemove: case Packets.Client_FriendRemove:
RemoveFriend(PacketUser, CurrentPacket.data); RemoveFriend(PacketUser, CurrentPacket.data);
break; break;
case Packets.Client_UserStatsRequest: case Packets.Client_UserStatsRequest:
UserStatsRequest(PacketUser, CurrentPacket.data); UserStatsRequest(PacketUser, CurrentPacket.data);
break; break;
case Packets.Client_SpecialMatchInfoRequest: case Packets.Client_SpecialMatchInfoRequest:
TourneyMatchSpecialInfo(PacketUser, CurrentPacket.data); TourneyMatchSpecialInfo(PacketUser, CurrentPacket.data);
break; break;
case Packets.Client_SpecialJoinMatchChannel: case Packets.Client_SpecialJoinMatchChannel:
TourneyMatchJoinChannel(PacketUser, CurrentPacket.data); TourneyMatchJoinChannel(PacketUser, CurrentPacket.data);
break; break;
case Packets.Client_SpecialLeaveMatchChannel: case Packets.Client_SpecialLeaveMatchChannel:
TourneyMatchLeaveChannel(PacketUser, CurrentPacket.data); TourneyMatchLeaveChannel(PacketUser, CurrentPacket.data);
break; break;
case Packets.Client_Invite: case Packets.Client_Invite:
//MultiplayerInvite(PacketUser, CurrentPacket.data); //MultiplayerInvite(PacketUser, CurrentPacket.data);
break; break;
case Packets.Client_UserPresenceRequest: case Packets.Client_UserPresenceRequest:
UserPresence(PacketUser, PacketUser.id); // Can't really think of a way to generalize this? UserPresence(PacketUser, PacketUser.id);
break; break;
// Ignored packets
case Packets.Client_Pong:
case Packets.Client_BeatmapInfoRequest:
case Packets.Client_ReceiveUpdates:
break;
default: default:
// Ignore client_beatmapInfoRequest and client_receiveUpdates
if (CurrentPacket.id == 68 || CurrentPacket.id == 79 || CurrentPacket.id == 4) break;
// Print out unimplemented packet // Print out unimplemented packet
console.dir(CurrentPacket); console.dir(CurrentPacket);
break; break;
} }
} }
@ -290,7 +294,7 @@ export default async function HandleRequest(req:IncomingMessage, res:ServerRespo
PacketUser.clearQueue(); PacketUser.clearQueue();
} else { } else {
// User's token is invlid, force a reconnect // User's token is invlid, force a reconnect
ConsoleHelper.printBancho(`Forced client re-login (Token is invalid)`); ConsoleHelper.printBancho(`Forced client re-connect (Token is invalid)`);
const osuPacketWriter = osu.Bancho.Writer(); const osuPacketWriter = osu.Bancho.Writer();
osuPacketWriter.Announce("Reconnecting..."); osuPacketWriter.Announce("Reconnecting...");
osuPacketWriter.Restart(0); osuPacketWriter.Restart(0);

View file

@ -192,8 +192,6 @@ export default async function LoginProcess(req:IncomingMessage, res:ServerRespon
UserPresenceBundle(newUser); UserPresenceBundle(newUser);
osuPacketWriter.Announce(`Welcome back ${loginInfo.username}!`); osuPacketWriter.Announce(`Welcome back ${loginInfo.username}!`);
// TODO: Remove once merged into master
osuPacketWriter.Announce("Heads up!\nWhile the TypeScript server rewrite is mostly stable it still has some issues.");
} catch (err) { } catch (err) {
console.error(err); console.error(err);
} }