Implement private messages
This commit is contained in:
parent
93e7aa61d0
commit
de5b4841de
2 changed files with 25 additions and 0 deletions
20
server/Packets/SendPrivateMessage.js
Normal file
20
server/Packets/SendPrivateMessage.js
Normal 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);
|
||||
}
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue