Implement private messages

This commit is contained in:
tgpethan 2020-09-02 10:57:12 +01:00
parent 93e7aa61d0
commit de5b4841de
2 changed files with 25 additions and 0 deletions

View file

@ -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);
}

View file

@ -84,6 +84,7 @@ const ChangeAction = require("./Packets/ChangeAction.js"),
SendPublicMessage = require("./Packets/SendPublicMessage.js"), SendPublicMessage = require("./Packets/SendPublicMessage.js"),
Logout = require("./Packets/Logout.js"), Logout = require("./Packets/Logout.js"),
Spectator = require("./Spectator.js"), Spectator = require("./Spectator.js"),
SendPrivateMessage = require("./Packets/SendPrivateMessage.js"),
Multiplayer = require("./Multiplayer.js"), Multiplayer = require("./Multiplayer.js"),
ChannelPart = require("./Packets/ChannelPart.js"), ChannelPart = require("./Packets/ChannelPart.js"),
UserPresenceBundle = require("./Packets/UserPresenceBundle.js"), UserPresenceBundle = require("./Packets/UserPresenceBundle.js"),
@ -160,6 +161,10 @@ module.exports = function(req, res) {
Spectator.stopSpectatingUser(userClass); Spectator.stopSpectatingUser(userClass);
break; break;
case packetIDs.client_sendPrivateMessage:
SendPrivateMessage(CurrentPacket, userClass);
break;
case packetIDs.client_joinLobby: case packetIDs.client_joinLobby:
Multiplayer.userEnterLobby(userClass); Multiplayer.userEnterLobby(userClass);
break; break;