当前位置: 首页>>代码示例>>C#>>正文


C# IConnection.SetTimeout方法代码示例

本文整理汇总了C#中IConnection.SetTimeout方法的典型用法代码示例。如果您正苦于以下问题:C# IConnection.SetTimeout方法的具体用法?C# IConnection.SetTimeout怎么用?C# IConnection.SetTimeout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IConnection的用法示例。


在下文中一共展示了IConnection.SetTimeout方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandleConnection

        public async Task HandleConnection(IConnection connection)
        {
            _connection = connection;
            
            try
            {
                _connection.SetTimeout(_configuration.EnvelopeCommandTimeout);
                // Handle banner message
                var reply = await ReadUntilNewLine(_connection);

                // Send HELO
                await SendLine("HELO " + _configuration.HostName);
                reply = await ReadUntilNewLine(_connection);

                // Send MAIL FROM
                await SendLine("MAIL FROM:<" + _messageData.From + ">");
                reply = await ReadUntilNewLine(_connection);


                // Send RCPT TO
                foreach (var recipient in _messageData.Recipients)
                {
                    await SendLine("RCPT TO:<" + recipient + ">");
                    reply = await ReadUntilNewLine(_connection);
                }

                await SendLine("DATA");
                reply = await ReadUntilNewLine(_connection);

                // Send DATA
                await SendLine("DATA");

                //_connection.WriteBytes()

                await SendLine(".");
                reply = await ReadUntilNewLine(_connection);


                // Send Actual data
                await SendLine("QUIT");
                reply = await ReadUntilNewLine(_connection);
            }
            catch (DisconnectedException)
            {
                // Connection gone.
            }
        }
开发者ID:hmailserver,项目名称:hmailserver-net,代码行数:47,代码来源:SmtpClientSession.cs

示例2: HandleConnection

        public async Task HandleConnection(IConnection connection)
        {
            _connection = connection;

            try
            {
                await SendBanner();

                while (true)
                {
                    _connection.SetTimeout(_configuration.CommandTimeout);

                    var data = await ReadUntilNewLine(_connection);

                    _log.LogInfo(new LogEvent()
                        {
                            Message = data,
                            RemoteEndpoint = _connection.RemoteEndpoint,
                            SessionId = _connection.SessionId
                        });

                    var command = IMAP.CommandParser.ParseCommand(data);

                    if (!_state.IsCommandValid(command))
                    {
                        await SendCommandResult(new Pop3CommandReply(false, "Invalid command in current state"));
                        continue;
                    }

                    switch (command)
                    {
                        default:
                            throw new DisconnectedException();
                    }
                }
            }
            catch (DisconnectedException)
            {
                // Connection gone.
            }
        }
开发者ID:hmailserver,项目名称:hmailserver-net,代码行数:41,代码来源:ImapServerSesson.cs

示例3: HandleConnection

        public async Task HandleConnection(IConnection connection)
        {
            _connection = connection;

            try
            {
                await SendBanner();

                while (true)
                {
                    _connection.SetTimeout(_configuration.CommandTimeout);

                    var data = await ReadUntilNewLine(_connection);

                    _log.LogInfo(new LogEvent()
                        {
                            Message = data,
                            RemoteEndpoint = _connection.RemoteEndpoint,
                            SessionId = _connection.SessionId
                        });

                    var command = POP3.CommandParser.ParseCommand(data);

                    if (!_state.IsCommandValid(command))
                    {
                        await SendCommandResult(new Pop3CommandReply(false, "Invalid command in current state"));
                        continue;
                    }

                    switch (command)
                    {
                        case Pop3Command.Capa:
                            await HandleCapa();
                            break;
                        case Pop3Command.Help:
                            await HandleHelp();
                            break;
                        case Pop3Command.User:
                            await HandleUser(data);
                            break;
                        case Pop3Command.Pass:
                            await HandlePass(data);
                            break;
                        case Pop3Command.Stat:
                            await HandleStat();
                            break;
                        case Pop3Command.List:
                            await HandleList();
                            break;
                        case Pop3Command.Uidl:
                            await HandleUidl();
                            break;
                        case Pop3Command.Retr:
                            await HandleRetr(data);
                            break;
                        case Pop3Command.Dele:
                            await HandleDele(data);
                            break;
                        case Pop3Command.Quit:
                            await HandleQuit();
                            throw new DisconnectedException();
                    }
                }
            }
            catch (DisconnectedException)
            {
                // Connection gone.
            }
        }
开发者ID:hmailserver,项目名称:hmailserver-net,代码行数:69,代码来源:Pop3ServerSesson.cs

示例4: HandleConnection

        public async Task HandleConnection(IConnection connection)
        {
            _connection = connection;

            try
            {
                await SendBanner();

                while (true)
                {
                    _connection.SetTimeout(_configuration.EnvelopeCommandTimeout);

                    var data = await ReadUntilNewLine(_connection);

                    _log.LogInfo(new LogEvent()
                        {
                            Message = data,
                            RemoteEndpoint = _connection.RemoteEndpoint,
                            SessionId = _connection.SessionId
                        });

                    var command = CommandParser.ParseCommand(data);

                    if (!_state.IsCommandValid(command))
                    {
                        await SendCommandResult(new SmtpCommandReply(503, "bad sequence of commands"));
                        continue;
                    }

                    switch (command)
                    {
                        case SmtpCommand.Help:
                            await HandleHelp();
                            break;
                        case SmtpCommand.Rset:
                            await HandleRset();
                            _state.HasMailFrom = false;
                            _state.HasRcptTo = false;
                            break;
                        case SmtpCommand.Helo:
                            await HandleHelo(data);
                            break;
                        case SmtpCommand.Ehlo:
                            await HandleEhlo(data);
                            break;
                        case SmtpCommand.StartTls:
                            await HandleStartTls();
                            break;
                        case SmtpCommand.Mail:
                            await HandleMailFrom(data);
                            break;
                        case SmtpCommand.Rcpt:
                            await HandleRcptTo(data);
                            break;
                        case SmtpCommand.Data:
                            await HandleData();
                            break;
                        case SmtpCommand.Quit:
                            await HandleQuit();
                            throw new DisconnectedException();

                    }
                }
            }
            catch (DisconnectedException)
            {
                // Connection gone.
            }
        }
开发者ID:hmailserver,项目名称:hmailserver-net,代码行数:69,代码来源:SmtpServerSession.cs


注:本文中的IConnection.SetTimeout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。