Esempio n. 1
0
        bool IDataSender.UpdateEmailReq(Guid request_id, UpdateEmailReq req)
        {
            Datagram datagram = new Datagram
            {
                DataType    = DatagramType.Login,
                MessageType = LoginMessageType.UpdateEmailReq,
                RequestID   = request_id,
                Datas       = req.ToByteArray()
            };

            return(Send(datagram));
        }
Esempio n. 2
0
        private void OnUpdateEmailReq(Datagram datagram)
        {
            UpdateEmailReq req = datagram.UnSerialData <UpdateEmailReq>();

            UpdateEmailResponse response = new UpdateEmailResponse();

            if (!SQLDB.CheckEmail(req.UserEmail))
            {
                if (SQLDB.SelectUserInfor(req.UserID, out UserInfoPackage info))
                {
                    Guid request_id = Guid.NewGuid();

                    byte[] ver_code = InternalTools.GenerateVerification();
                    if (EmailRequestCache.TryAdd(request_id, new EmailRequestPackage
                    {
                        UserID = info.ID,
                        Email = req.UserEmail,
                        Verify = ver_code,
                        Time = DateTime.Now
                    }))
                    {
                        if (
                            InternalTools.SendUpdateEmailVerificateEmail
                            (
                                req.UserEmail,
                                InternalTools.GenerateVerification(ver_code)
                            )
                            )
                        {
                            response.NextLabel = request_id;
                        }
                    }
                }
            }

            datagram.DataType    = DatagramType.Client;
            datagram.MessageType = LoginMessageType.UpdateEmailRes;
            datagram.Datas       = response.ToByteArray();

            if (!Send(datagram.ToByteArray()))
            {
                Notify(IKXTServer.LogLevel.Error, "数据发送异常");
                Close();
            }
        }