/// <summary> /// A class used to connect to an IRC server /// </summary> /// <param name="Configuration">The Configuration to use when connecting</param> public Client(Config Configuration) { // Initialise regex BEFORE we connect ServerMessageRegex = new Regex(@":([A-Za-z0-9\.\-]+) ([0-9]+) ([0-9A-Za-z_\-\[\]\{\}\\`\|\*]+) (.+)"); CommandRegex = new Regex(@":([0-9A-Za-z_\-\[\]\{\}\\`\|]+)!~([0-9A-Za-z_\-\[\]\{\}\\`\|]+)@([A-Za-z0-9\.\-:\/]+) ([A-Z]+) (.+)"); Connection = new TcpClient(Configuration.Host, Configuration.Port); Connection.NoDelay = true; NetStream = Connection.GetStream(); Reader = new StreamReader(NetStream); this.Configuration = Configuration; CommandQueue = new ThreadSafeObject <Queue <string> > (new Queue <string> ()); ShouldClose = new ThreadSafeStruct <bool> (false); SendData(string.Format("USER {0} * * {0}", Configuration.Username)); SendData(string.Format("NICK {0}", Configuration.Nick)); NetThread = new Thread((ThreadStart) delegate { this.BackThread(); }); Channels = new Dictionary <string, Channel> (); DirectMessages = new ThreadSafeObject <Dictionary <string, Queue <string> > > (new Dictionary <string, Queue <string> > ()); Had001 = new ThreadSafeStruct <bool> (false); // Start Thread NetThread.Start(); // Wait for 001; SpinWait.SpinUntil(() => Had001.Get()); }
internal Channel(Client Parent, String ChannelName) { this.ChannelName = ChannelName; this.Parent = Parent; Response = StatusCode.None; MessageQueue = new ThreadSafeObject <Queue <Message> > (new Queue <Message> ()); Inside_Users = new List <string> (); EndOfNames = false; }