diff --git a/server/Packets/SendPrivateMessage.js b/server/Packets/SendPrivateMessage.js new file mode 100644 index 0000000..4d7ddaa --- /dev/null +++ b/server/Packets/SendPrivateMessage.js @@ -0,0 +1,20 @@ +const osu = require("osu-packet"), + getUserByUsername = require("../util/getUserByUsername.js"); + +module.exports = function(CurrentPacket, CurrentUser) { + const osuPacketWriter = new osu.Bancho.Writer; + + osuPacketWriter.ChannelJoinSuccess(CurrentUser.username); + + osuPacketWriter.SendMessage({ + sendingClient: CurrentUser.username, + message: CurrentPacket.data.message, + target: CurrentPacket.data.target, + senderId: CurrentUser.id + }); + + const userSentTo = getUserByUsername(CurrentPacket.data.target); + + // Write chat message to stream asociated with chat channel + return userSentTo.addActionToQueue(osuPacketWriter.toBuffer); +} \ No newline at end of file diff --git a/server/serverHandler.js b/server/serverHandler.js index d8076ea..7367e61 100644 --- a/server/serverHandler.js +++ b/server/serverHandler.js @@ -84,6 +84,7 @@ const ChangeAction = require("./Packets/ChangeAction.js"), SendPublicMessage = require("./Packets/SendPublicMessage.js"), Logout = require("./Packets/Logout.js"), Spectator = require("./Spectator.js"), + SendPrivateMessage = require("./Packets/SendPrivateMessage.js"), Multiplayer = require("./Multiplayer.js"), ChannelPart = require("./Packets/ChannelPart.js"), UserPresenceBundle = require("./Packets/UserPresenceBundle.js"), @@ -160,6 +161,10 @@ module.exports = function(req, res) { Spectator.stopSpectatingUser(userClass); break; + case packetIDs.client_sendPrivateMessage: + SendPrivateMessage(CurrentPacket, userClass); + break; + case packetIDs.client_joinLobby: Multiplayer.userEnterLobby(userClass); break;