bool IDataSender.RegistEmailReq(Guid request_id, RegistEmailReq req) { Datagram datagram = new Datagram { DataType = DatagramType.Login, MessageType = LoginMessageType.RegistEmailReq, RequestID = request_id, Datas = req.ToByteArray() }; return(Send(datagram)); }
private void OnRegistEmailReq(Datagram datagram) { RegistEmailReq req = datagram.UnSerialData <RegistEmailReq>(); RegistResponse response = new RegistResponse(); if (SQLDB.CheckEmail(req.Email)) { Guid request_id = Guid.NewGuid(); byte[] ver_code = InternalTools.GenerateVerification(); if (EmailRequestCache.TryAdd(request_id, new EmailRequestPackage { UserID = null, Email = req.Email, Verify = ver_code, Time = DateTime.Now })) { if ( InternalTools.SendRegistVerificateEmail ( req.Email, InternalTools.GenerateVerification(ver_code) ) ) { response.NextLabel = request_id; } } } datagram.DataType = DatagramType.Client; datagram.MessageType = LoginMessageType.RegistEmailRes; datagram.Datas = response.ToByteArray(); if (!Send(datagram.ToByteArray())) { Notify(IKXTServer.LogLevel.Error, "数据发送异常"); Close(); } }