Implement friends list functionality
This commit is contained in:
parent
888330ea0f
commit
3e15b9ada3
5 changed files with 29 additions and 3 deletions
|
@ -5,12 +5,12 @@ An implementation of osu!bancho in Javascript
|
|||
### Features:
|
||||
- Multiplayer + Invites
|
||||
- Spectator
|
||||
- User Panel (Missing Friends)
|
||||
- User Panel
|
||||
- Friends List
|
||||
- Chat & Channels
|
||||
- Private Messages
|
||||
|
||||
### Currently unimplemented things:
|
||||
- Friends List
|
||||
- Bot
|
||||
|
||||
## Bugs:
|
||||
|
|
5
server/Packets/AddFriend.js
Normal file
5
server/Packets/AddFriend.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
const DatabaseHelper = require("../DatabaseHelper.js");
|
||||
|
||||
module.exports = function(CurrentUser, FriendToAdd) {
|
||||
DatabaseHelper.getFromDB(`INSERT INTO friends (user, friendsWith) VALUES (${CurrentUser.id}, ${FriendToAdd});`);
|
||||
}
|
5
server/Packets/RemoveFriend.js
Normal file
5
server/Packets/RemoveFriend.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
const DatabaseHelper = require("../DatabaseHelper.js");
|
||||
|
||||
module.exports = function(CurrentUser, FriendToRemove) {
|
||||
DatabaseHelper.getFromDB(`DELETE FROM friends WHERE user = ${CurrentUser.id} AND friendsWith = ${FriendToRemove} LIMIT 1`);
|
||||
}
|
|
@ -86,8 +86,14 @@ module.exports = function(req, res, loginInfo) {
|
|||
osuPacketWriter.ProtocolNegotiation(19);
|
||||
// Permission level 4 is osu!supporter
|
||||
osuPacketWriter.LoginPermissions(4);
|
||||
// Construct user's friends list
|
||||
const userFriends = DatabaseHelper.getListFromDB(`SELECT friendsWith FROM friends WHERE user = ${userClass.id}`);
|
||||
let friendsArray = [];
|
||||
for (let i = 0; i < userFriends.length; i++) {
|
||||
friendsArray.push(userFriends[i].friendsWith);
|
||||
}
|
||||
// Send user's friends list
|
||||
// TODO: friends? Haha, you have no friends!
|
||||
osuPacketWriter.FriendsList(friendsArray);
|
||||
// Set title screen image
|
||||
osuPacketWriter.TitleUpdate("http://puu.sh/jh7t7/20c04029ad.png|https://osu.ppy.sh/news/123912240253");
|
||||
|
||||
|
|
|
@ -87,6 +87,8 @@ const ChangeAction = require("./Packets/ChangeAction.js"),
|
|||
SendPrivateMessage = require("./Packets/SendPrivateMessage.js"),
|
||||
Multiplayer = require("./Multiplayer.js"),
|
||||
ChannelPart = require("./Packets/ChannelPart.js"),
|
||||
AddFriend = require("./Packets/AddFriend.js"),
|
||||
RemoveFriend = require("./Packets/RemoveFriend.js"),
|
||||
UserPresenceBundle = require("./Packets/UserPresenceBundle.js"),
|
||||
UserPresence = require("./Packets/UserPresence.js"),
|
||||
UserStatsRequest = require("./Packets/UserStatsRequest.js"),
|
||||
|
@ -246,6 +248,14 @@ module.exports = function(req, res) {
|
|||
ChannelPart(userClass, CurrentPacket.data);
|
||||
break;
|
||||
|
||||
case packetIDs.client_friendAdd:
|
||||
AddFriend(userClass, CurrentPacket.data);
|
||||
break;
|
||||
|
||||
case packetIDs.client_friendRemove:
|
||||
RemoveFriend(userClass, CurrentPacket.data);
|
||||
break;
|
||||
|
||||
case packetIDs.client_userStatsRequest:
|
||||
UserStatsRequest(userClass, CurrentPacket.data);
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue