From e9fd3993a80d853352cbdc97c28c2fe5e8574468 Mon Sep 17 00:00:00 2001 From: tgpethan Date: Wed, 2 Sep 2020 11:31:06 +0100 Subject: [PATCH] Implement multiplayer invites --- README.md | 3 +-- server/Packets/MultiplayerInvite.js | 17 +++++++++++++++++ server/serverHandler.js | 7 ++++++- 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 server/Packets/MultiplayerInvite.js diff --git a/README.md b/README.md index 46f3fb0..98d50b0 100644 --- a/README.md +++ b/README.md @@ -3,14 +3,13 @@ An implementation of osu!bancho in Javascript
### Features: - - Multiplayer + - Multiplayer + Invites - Spectator - User Panel (Missing Friends) - Chat & Channels - Private Messages ### Currently unimplemented things: - - Multiplayer Invites - Friends List - Bot diff --git a/server/Packets/MultiplayerInvite.js b/server/Packets/MultiplayerInvite.js new file mode 100644 index 0000000..e1daaa6 --- /dev/null +++ b/server/Packets/MultiplayerInvite.js @@ -0,0 +1,17 @@ +const osu = require("osu-packet"), + getUserById = require("../util/getUserById.js"); + +module.exports = function(CurrentUser, InvitedUser) { + let osuPacketWriter = new osu.Bancho.Writer; + + const InvitedUserClass = getUserById(InvitedUser); + + osuPacketWriter.SendMessage({ + sendingClient: CurrentUser.username, + message: `Come join my multiplayer match: [osump://${CurrentUser.currentMatch}/ ${global.matches[CurrentUser.currentMatch][1].gameName}]`, + target: CurrentUser.username, + senderId: CurrentUser.id + }); + + InvitedUserClass.addActionToQueue(osuPacketWriter.toBuffer); +} \ No newline at end of file diff --git a/server/serverHandler.js b/server/serverHandler.js index 7367e61..63db5ad 100644 --- a/server/serverHandler.js +++ b/server/serverHandler.js @@ -89,7 +89,8 @@ const ChangeAction = require("./Packets/ChangeAction.js"), ChannelPart = require("./Packets/ChannelPart.js"), UserPresenceBundle = require("./Packets/UserPresenceBundle.js"), UserPresence = require("./Packets/UserPresence.js"), - UserStatsRequest = require("./Packets/UserStatsRequest.js"); + UserStatsRequest = require("./Packets/UserStatsRequest.js"), + MultiplayerInvite = require("./Packets/MultiplayerInvite.js"); module.exports = function(req, res) { // Add to requests for logging @@ -249,6 +250,10 @@ module.exports = function(req, res) { UserStatsRequest(userClass, CurrentPacket.data); break; + case packetIDs.client_invite: + MultiplayerInvite(userClass, CurrentPacket.data); + break; + case packetIDs.client_userPresenceRequest: UserPresence(userClass, userClass.id); break;