예제 #1
0
 private void MessageReceived_PING(object sender, MessageReceivedEventArgs e)
 {
     if (String.Compare(e.Message.Command, "PING", true) != 0)
     {
         return;
     }
     Send(IRCMessage.CreateMessage("PONG :" + e.Message.CommandParam));
 }
예제 #2
0
        /// <summary>
        /// セッションを開始します。
        /// </summary>
        public void Start()
        {
            CheckDisposed();
            try
            {
                using (Stream stream = TcpClient.GetStream())
                {
                    Stream targetStream = stream;
                    if (CurrentServer.IsSslConnection)
                    {
                        SslStream sslStream = new SslStream(stream);
                        sslStream.AuthenticateAsServer(CurrentServer.Certificate, false, SslProtocols.Default, false);
                        targetStream = sslStream;
                    }

                    using (StreamReader sr = new StreamReader(targetStream, Encoding))
                        using (StreamWriter sw = new StreamWriter(targetStream, Encoding))
                        {
                            _writer = sw;

                            String        line;
                            PermissionSet permissionSet = null;
                            while (TcpClient.Connected && (line = sr.ReadLine()) != null)
                            {
                                try
                                {
                                    IRCMessage msg = IRCMessage.CreateMessage(line);
                                    OnMessageReceived(msg);
                                }
                                catch (IRCException ircE)
                                {
                                    Trace.TraceWarning(ircE.ToString());
                                }
                            }
                        }
                }
            }
            //catch (IOException)
            //{
            //}
            //catch (NullReferenceException)
            //{
            //}
            //catch (AuthenticationException) // SSL
            //{
            //}
            catch (Exception ex)
            {
                TraceLogger.Server.Error("Error: {0}", ex.ToString());
            }
            finally
            {
                Close();
            }
        }