コード例 #1
0
        public static void RejectFriendRequest(int _fromClient, Packet _packet)
        {
            int _toClientID   = _packet.ReadInt();
            int _fromClientID = _packet.ReadInt();

            using (SqliteDataAccess _db = new SqliteDataAccess())
            {
                if (_db.GetFriendRequest(_fromClientID, _toClientID))
                {
                    _db.RemoveFriendRequest(_fromClientID, _toClientID);

                    ServerSend.FriendshipRequestHandled(_fromClient, "Friend request removed.");
                }
            }
        }
コード例 #2
0
        public static void AcceptFriendRequest(int _fromClient, Packet _packet)
        {
            int _toClientID   = _packet.ReadInt(); //User that received request
            int _fromClientID = _packet.ReadInt(); //User that sent request

            using (SqliteDataAccess _db = new SqliteDataAccess())
            {
                if (_db.GetFriendRequest(_fromClientID, _toClientID))
                {
                    Console.WriteLine($"User {_db.GetUserData(_toClientID).username} accepted friend request from {_db.GetUserData(_fromClientID).username}");
                    _db.AcceptFriendRequest(_fromClientID, _toClientID);
                    _db.AcceptFriendRequest(_toClientID, _fromClientID);
                    _db.RemoveFriendRequest(_fromClientID, _toClientID);

                    ServerSend.FriendshipRequestHandled(_fromClient, "Friend added.");
                }
            }
        }
コード例 #3
0
        public static void SendFriendRequest(int _fromClient, Packet _packet)
        {
            int _fromClientID = _packet.ReadInt();
            int _toClientID   = _packet.ReadInt();

            using (SqliteDataAccess _db = new SqliteDataAccess())
            {
                if (!_db.GetFriendRequest(_fromClientID, _toClientID))
                {
                    _db.SendFriendRequest(_fromClientID, _toClientID);

                    ServerSend.FriendshipRequestHandled(_fromClient, "Friend request sent.");
                }
                else
                {
                    ServerSend.FriendshipRequestHandled(_fromClient, "The ID you inserted doesn't belong to anyone. Please try again.");
                }
            }
        }