Beta Sprint3

Beta Sprint3

catalogue

1.Achievements
2. Some important codes
3. SCRUM meeting
4.Expected tasks and completed tasks
5.Project Burnout Diagram
6.Task Total Change Chart
7. Result presentation

I.SCRUM section

1.Achievements

Recent Task DescriptionMembersLinks
Implementation of adding friends function[8h]汪郑贤【832102222_21124744】https://github.com/Tyler-Linchenwei/chat
Server-side code optimization[4h]温宗彦【832102228_21126895】https://github.com/Tyler-Linchenwei/chat
Client code optimization[4h]王心怡【832101201_21124477】https://github.com/Tyler-Linchenwei/chat

After these few days of progress, our project is almost complete, with the optimization of client and server code, as well as the beautification of our original UI interface. We will present our final results at the end of the blog.

2. Some important codes
The following code is the optimization result of our server-side code. The original use of command line is changed to use Jason, so that we can modify user information directly outside.

//------------------------------------------------------------
// 偷我的代码就会被拖进黑暗空间
// Copyright © 2023 Molth Nevin. All rights reserved.
//------------------------------------------------------------

using CommandLine;
using Newtonsoft.Json;

#pragma warning disable CS8600
#pragma warning disable CS8602
#pragma warning disable CS8618

namespace Erinn
{
    /// <summary>
    ///     程序入口
    /// </summary>
    public static class Entry
    {
        /// <summary>
        ///     入口方法
        /// </summary>
        public static async Task Main()
        {
            ConnectThirdParty();
            var server = new MasterServer();
            server.Init(NetworkProtocolType.Kcp);
            server.ChangeLog(false);
            _ = new MessageManager(server);
            server.Start(7777);
            await server.Update();
        }

        /// <summary>
        ///     连接第三方
        /// </summary>
        private static void ConnectThirdParty()
        {
            var jsonData = File.ReadAllText(Path.Combine(Environment.CurrentDirectory, "CommandLineOptions.txt"));
            var options = JsonConvert.DeserializeObject<CommandLineOptions>(jsonData);
            var mySqlSetting = options.MySqlSetting.Split(',');
            MySqlService.Connect(mySqlSetting[0], mySqlSetting[1], mySqlSetting[2], mySqlSetting[3], mySqlSetting[4]);
            var mailSetting = options.MailSetting.Split(',');
            MailService.Connect(mailSetting[0], mailSetting[1], mailSetting[2], mailSetting[3]);
            var baiduSetting = options.BaiduSetting.Split(',');
            BaiduService.Connect(baiduSetting[0], baiduSetting[1], baiduSetting[2]);
        }

        /// <summary>
        ///     命令行选项
        /// </summary>
        public sealed record CommandLineOptions
        {
            /// <summary>
            ///     数据库
            /// </summary>
            [Option("MySql", Required = true, Default = null)]
            public string MySqlSetting { get; set; }

            /// <summary>
            ///     邮箱
            /// </summary>
            [Option("Mail", Required = true, Default = null)]
            public string MailSetting { get; set; }

            /// <summary>
            ///     百度
            /// </summary>
            [Option("Baidu", Required = true, Default = null)]
            public string BaiduSetting { get; set; }
        }
    }
}


The following code is the optimization result of our client code. The content of the client object pool has been optimized from the original need to be deleted and reset to be reused directly to reduce space.

//------------------------------------------------------------
// 偷我的代码就会被拖进黑暗空间
// Copyright © 2023 Molth Nevin. All rights reserved.
//------------------------------------------------------------

using System.Net;
using MemoryPack;
using Sirenix.OdinInspector;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

namespace Erinn
{
    /// <summary>
    ///     主面板类,用于管理聊天客户端的主界面和相关操作
    /// </summary>
    public sealed class MainPanel : MonoSingleton<MainPanel>, IRpcCallback
    {
        /// <summary>
        ///     服务器地址
        /// </summary>
        [LabelText("地址")] public string Address = "127.0.0.1";

        /// <summary>
        ///     服务器端口
        /// </summary>
        [LabelText("端口")] public uint Port = 7777;

        /// <summary>
        ///     登录提示文本
        /// </summary>
        [Header("")] [LabelText("登录提示")] public TMP_Text loginTip;

        /// <summary>
        ///     登录邮箱输入框
        /// </summary>
        [LabelText("登录邮箱")] public TMP_InputField loginEmail;

        /// <summary>
        ///     登录密码输入框
        /// </summary>
        [LabelText("登录密码")] public TMP_InputField loginUserpassword;

        /// <summary>
        ///     注册提示文本
        /// </summary>
        [LabelText("注册提示")] public TMP_Text registerTip;

        /// <summary>
        ///     注册邮箱输入框
        /// </summary>
        [LabelText("注册邮箱")] public TMP_InputField registerEmail;

        /// <summary>
        ///     注册用户名输入框
        /// </summary>
        [LabelText("注册用户名")] public TMP_InputField registerUsername;

        /// <summary>
        ///     注册密码输入框
        /// </summary>
        [LabelText("注册密码")] public TMP_InputField registerUserpassword;

        /// <summary>
        ///     注册验证码输入框
        /// </summary>
        [LabelText("注册验证码")] public TMP_InputField registerEmailcode;

        /// <summary>
        ///     登录面板游戏对象
        /// </summary>
        [Header("")] [LabelText("登录")] public GameObject LoginPanel;

        /// <summary>
        ///     注册面板游戏对象
        /// </summary>
        [LabelText("注册")] public GameObject RegisterPanel;

        /// <summary>
        ///     分组面板游戏对象
        /// </summary>
        [LabelText("组")] public GameObject GroupPanel;

        /// <summary>
        ///     好友预制体
        /// </summary>
        [Header("")] [LabelText("朋友")] public Friend FriendPrefab;

        /// <summary>
        ///     好友对象池的父物体
        /// </summary>
        [LabelText("朋友池")] public Transform FriendPool;

        /// <summary>
        ///     待处理好友预制体
        /// </summary>
        [Header("")] [LabelText("待处理好友预制件")] public PendingFriend PendingFriendPrefab;

        /// <summary>
        ///     待处理好友对象池的父物体
        /// </summary>
        [LabelText("待处理好友池")] public Transform PendingPool;

        /// <summary>
        ///     聊天面板组件
        /// </summary>
        [Header("")] [LabelText("聊天面板")] public ChatPanel ChatPanel;

        /// <summary>
        ///     输入好友名称的输入框
        /// </summary>
        [LabelText("好友名称")] public TMP_InputField FriendInput;

        /// <summary>
        ///     登录按钮
        /// </summary>
        [LabelText("登录按钮")] public Button LoginButton;

        /// <summary>
        ///     通讯录按钮
        /// </summary>
        [LabelText("通讯录按钮")] public Button TongXunLu;

        /// <summary>
        ///     注册按钮
        /// </summary>
        [LabelText("注册按钮")] public Button RegisterButton;

        /// <summary>
        ///     发送验证码按钮
        /// </summary>
        [LabelText("发送验证码按钮")] public Button SendEmailcodeButton;

        /// <summary>
        ///     发送好友请求按钮
        /// </summary>
        [LabelText("发送好友请求按钮")] public Button SendFriendButton;

        /// <summary>
        ///     通讯录面板的游戏对象
        /// </summary>
        [LabelText("通讯录面板")] public GameObject TongXunLuPanelGo;

        /// <summary>
        ///     聊天名称显示文本
        /// </summary>
        [LabelText("聊天名称")] public TMP_Text ChatName;

        /// <summary>
        ///     聊天面板组件
        /// </summary>
        [LabelText("聊天面板组件")] public ChatPanel chatPanel;

        /// <summary>
        ///     隐藏池1
        /// </summary>
        [LabelText("隐藏池1")] public Transform HidePool;

        /// <summary>
        ///     隐藏池2
        /// </summary>
        [LabelText("隐藏池2")] public Transform HidePool2;

        /// <summary>
        ///     在对象启动时调用的方法,初始化相关组件和事件监听器
        /// </summary>
        private void Start()
        {
            Screen.sleepTimeout = 600;
            chatPanel.OnAwake();
            NetworkTransport.Singleton.Master.RegisterHandlers(this, typeof(MainPanel));
            NetworkTransport.Singleton.Connect(IPAddress.Parse(Address), Port);
            LoginButton.onClick.AddListener(Login);
            TongXunLu.onClick.AddListener(GetFriends);
            TongXunLu.onClick.AddListener(GetPendingFriends);
            RegisterButton.onClick.AddListener(Register);
            SendEmailcodeButton.onClick.AddListener(SendEmailcode);
            SendFriendButton.onClick.AddListener(SendFriend);
        }

        /// <summary>
        ///     在聊天面板中显示
        /// </summary>
        public void ShowChat()
        {
            TongXunLuPanelGo.SetActive(false);
            chatPanel.gameObject.SetActive(true);
        }

        /// <summary>
        ///     处理聊天消息的方法
        /// </summary>
        [Rpc]
        private void OnMessageChat(MessageChat message)
        {
            ChatPanel.Receive(message.username, message.content);
        }

        /// <summary>
        ///     处理获取好友列表的方法
        /// </summary>
        [Rpc]
        private void OnGetFriends(ResponseGetFriends response)
        {
            var children = new Transform[FriendPool.childCount];
            for (var i = 0; i < FriendPool.childCount; ++i)
            {
                children[i] = FriendPool.GetChild(i);
            }

            for (var i = 0; i < children.Length; ++i)
            {
                children[i].SetParent(HidePool, false);
                var friend = children[i].GetComponent<Friend>();
                Entry.Pool.Push(friend);
            }

            for (var i = 0; i < response.friends.Count; ++i)
            {
                var friend = Entry.Pool.Pop<Friend>();
                if (friend != null)
                {
                    friend.transform.SetParent(FriendPool, false);
                }
                else
                {
                    friend = Instantiate(FriendPrefab.gameObject, FriendPool, false).GetComponent<Friend>();
                }

                friend.Name.text = response.friends[i];
            }
        }

        /// <summary>
        ///     处理获取待处理好友列表的方法
        /// </summary>
        [Rpc]
        private void OnGetPendingFriends(ResponseGetPendingFriends response)
        {
            var children = new Transform[PendingPool.childCount];
            for (var i = 0; i < PendingPool.childCount; ++i)
            {
                children[i] = PendingPool.GetChild(i);
            }

            for (var i = 0; i < children.Length; ++i)
            {
                children[i].SetParent(HidePool2, false);
                var t = children[i].GetComponent<PendingFriend>();
                Entry.Pool.Push(t);
            }

            for (var i = 0; i < response.friends.Count; ++i)
            {
                var friend = Entry.Pool.Pop<PendingFriend>();
                if (friend != null)
                {
                    friend.transform.SetParent(PendingPool, false);
                }
                else
                {
                    friend = Instantiate(PendingFriendPrefab.gameObject, PendingPool, false).GetComponent<PendingFriend>();
                }

                friend.Name.text = response.friends[i];
            }
        }

        /// <summary>
        ///     处理登录响应的方法
        /// </summary>
        [Rpc]
        private void OnResponseLogin(ResponseLogin response)
        {
            loginTip.text = response.Message;
            if (response.Success)
            {
                LoginPanel.SetActive(false);
                RegisterPanel.SetActive(false);
                GroupPanel.SetActive(true);
            }
        }

        /// <summary>
        ///     获取好友列表的方法
        /// </summary>
        public void GetFriends()
        {
            Send(new RequestGetFriends());
        }

        /// <summary>
        ///     获取待处理好友列表的方法
        /// </summary>
        public void GetPendingFriends()
        {
            Send(new RequestGetPendingFriends());
        }

        /// <summary>
        ///     发送好友请求的方法
        /// </summary>
        public void SendFriend()
        {
            var username = FriendInput.text;
            if (string.IsNullOrEmpty(username))
                return;
            Send(new RequestFriend { username = username });
        }

        /// <summary>
        ///     处理注册响应的方法
        /// </summary>
        [Rpc]
        private void OnResponseRegister(ResponseRegister response) => registerTip.text = response.Message;

        /// <summary>
        ///     发送网络消息的通用方法
        /// </summary>
        private void Send<T>(T value) where T : struct, INetworkMessage, IMemoryPackable<T> => NetworkTransport.Singleton.Master.Send(value);

        /// <summary>
        ///     处理登录的方法
        /// </summary>
        public void Login()
        {
            var email = loginEmail.text;
            var userpassword = loginUserpassword.text;
            Send(new RequestLogin { email = email, userpassword = userpassword });
        }

        /// <summary>
        ///     处理注册的方法
        /// </summary>
        public void Register()
        {
            var email = registerEmail.text;
            var username = registerUsername.text;
            var userpassword = registerUserpassword.text;
            var emailcode = registerEmailcode.text;
            Send(new RequestRegister { email = email, username = username, userpassword = userpassword, emailcode = emailcode });
        }

        /// <summary>
        ///     发送验证码的方法
        /// </summary>
        public void SendEmailcode()
        {
            var email = registerEmail.text;
            Send(new RequestSendCode { email = email });
        }
    }
}


3. SCRUM meeting
在这里插入图片描述

PM report

4.Expected tasks and completed tasks

ProjectTime
Overall expected tasks for the near-term project5 tasks with an estimated total time of 240 hours
Basic UI design for chat interfacecompleted in 40 hours
UI interface optimizationcompleted in 32 hours
Implementation of adding friend related functionscompleted in 40 hours
Implementation of chat functioncompleted in 48 hours
Client code optimizationcompleted in 48 hours
Server-side code optimizationcompleted in 48 hours
UI page optimizationcompleted in 48 hours

5.Project Burnout Diagram

在这里插入图片描述

6.Task Total Change Chart

在这里插入图片描述

From setting the total amount of tasks before the start of the task to gradually deepening the project, we found that the tasks we initially set were too general and not detailed enough. And there are still some unfinished functions before some tasks. Based on the original expected tasks, we have added more detailed task descriptions and some new tasks.

7. Result presentation

entry page

register and login

add friends

chatting1

chatting2

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值