示例#1
0
        public void Read()
        {
            while (true)
            {
                IrcMessage message;
                try
                {
                    message = Stream.ReadMessage();
                }
                catch (Exception)
                {
                    IrcServer.UserLeft(this, "connection reset by peer");
                    Socket.Close();
                    return;
                }
                Idle = DateTime.Now;
                if (message.Command == null)
                {
                    continue;
                }
                string line = message.ToString();

                IrcCommand command = IrcCommand.Find(message.Command);
                if (command == null)
                {
                    Console.WriteLine(line);
                    continue;
                }
                if (command.RequireRegistered && !Mode.IsRegistered)
                {
                    Write(new IrcNumericResponce
                    {
                        NumericId = IrcNumericResponceId.ERR_NOTREGISTERED,
                        Message   = "You're not registered.",
                        Extra     = command.Name.ToUpper()
                    });
                }

                command.Run(this, message);
            }
        }
示例#2
0
 public void Quit(string reason)
 {
     _network.Join();
     Socket.Close();
     IrcServer.UserLeft(this, reason);
 }