private void ReceivePass(Msg.ReceiveLine msg) { if (msg.GetArgs() == "P@ssword1") { ConnectionHandler.Tell(new Msg.UserAuthenticated { User = _userName, OkMessage = String.Format("+OK user {0} is authenticated.", _userName) }); } else { SendErrResponse("invalid password."); } }
public void ReceiveUser(Msg.ReceiveLine msg) { var user = msg.GetArgs(); if (user == "User1") { SendOkResponse("found mailbox for {0}.", user); _userName = user; Become(ExpectPassCommand); } else { SendErrResponse("no such user: {0}.", user); } }
private void HandleList(Msg.ReceiveLine msg) { var args = msg.GetArgs(); if (args == "") { var messages = _mailDrop.Messages.ToArray(); SendMultilineResponse(String.Format("{0} messages ({1} octets)", messages.Length, messages.Sum(m => m.Size)), messages.Select(m => String.Format("{0} {1}", m.Number, m.Size)).ToArray()); return; } var mailMessage = GetMailMessage(msg); if (mailMessage != null) { SendOkResponse("{0} {1}", mailMessage.Number, mailMessage.Size); } }
private MailMessage GetMailMessage(Msg.ReceiveLine msg, bool includeDeleted = false) { MailMessage message = null; var args = msg.GetArgs(); int msgNum; if (args == "") { SendErrResponse("message number required."); } else if (!Int32.TryParse(args, out msgNum)) { SendErrResponse("invalid argument: {0}", args); } else { message = _mailDrop.GetMessage(msgNum, includeDeleted); if (message == null) { SendErrResponse("no such message."); } } return(message); }