示例#1
0
        /// <summary>
        /// Creates a new IRC client, but will not connect until ConnectAsync is called.
        /// </summary>
        /// <param name="serverAddress">Server address including port in the form of "hostname:port".</param>
        /// <param name="user">The IRC user to connect as.</param>
        /// <param name="useSSL">Connect with SSL if true.</param>
        public IrcClient(string serverAddress, IrcUser user, bool useSSL = false)
        {
            if (serverAddress == null)
            {
                throw new ArgumentNullException("serverAddress");
            }
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }

            User          = user;
            ServerAddress = serverAddress;
            Encoding      = Encoding.UTF8;
            Channels      = new ChannelCollection(this);
            Settings      = new ClientSettings();
            Handlers      = new Dictionary <string, MessageHandler>();
            MessageHandlers.RegisterDefaultHandlers(this);
            RequestManager = new RequestManager();
            UseSSL         = useSSL;
            WriteQueue     = new ConcurrentQueue <string>();
            ServerInfo     = new ServerInfo();
            PrivmsgPrefix  = "";
            Users          = new UserPool();
            Users.Add(User);               // Add self to user pool

            this.ConnectCompleted = false;
        }
示例#2
0
        /// <summary>
        /// Creates a new IRC client, but will not connect until ConnectAsync is called.
        /// </summary>
        /// <param name="serverAddress">Server address including port in the form of "hostname:port".</param>
        /// <param name="user">The IRC user to connect as.</param>
        /// <param name="useSSL">Connect with SSL if true.</param>
        public IrcClient(string serverAddress, IrcUser user, bool useSSL = false)
        {
            if (serverAddress == null)
            {
                throw new ArgumentNullException("serverAddress");
            }
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }

            user.Client   = this;
            User          = user;
            ServerAddress = serverAddress;
            Encoding      = Encoding.UTF8;
            Settings      = new ClientSettings();
            Handlers      = new Dictionary <string, MessageHandler>();
            MessageHandlers.RegisterDefaultHandlers(this);
            RequestManager = new RequestManager();
            UseSSL         = useSSL;
            WriteQueue     = new ConcurrentQueue <string>();
            ServerInfo     = new ServerInfo();
            PrivmsgPrefix  = "";
            Channels       = User.Channels = new ChannelCollection(this);
            Users          = new UserPool(this);
            Users.Add(User); // Add self to user pool
            Capabilities = new CapabilityPool();

            // List of supported capabilities
            Capabilities.AddRange(new string[] {
                "server-time", "multi-prefix", "cap-notify", "znc.in/server-time", "znc.in/server-time-iso",
                "account-notify", "chghost", "userhost-in-names", "sasl"
            });

            IsNegotiatingCapabilities = false;
            IsAuthenticatingSasl      = false;

            RandomNumber = new Random();
        }