private void ircChannelConnect(string channelname) { IrcChannelCollection channels = ircClient.Channels; try { channels.Join("#" + channelname.ToLower()); } catch (Exception e) { Debug.Print("Channel Join Exception: " + e.Message); } do { Thread.Sleep(100); } while (ircClient.Channels.Count <= 0); }
protected virtual void ResetState() { // Reset fully state of client. this.servers = new Collection<IrcServer>(); this.isRegistered = false; this.localUser = null; this.serverSupportedFeatures = new Dictionary<string, string>(); this.serverSupportedFeaturesReadOnly = new ReadOnlyDictionary<string, string>(this.serverSupportedFeatures); this.channelUserModes = new Collection<char>() { 'o', 'v' }; this.channelUserModesReadOnly = new ReadOnlyCollection<char>(this.channelUserModes); this.channelUserModesPrefixes = new Dictionary<char, char>() { { '@', 'o' }, { '+', 'v' } }; this.motdBuilder = new StringBuilder(); this.networkInformation = new IrcNetworkInfo(); this.channels = new Collection<IrcChannel>(); this.channelsReadOnly = new IrcChannelCollection(this, this.channels); this.users = new Collection<IrcUser>(); this.usersReadOnly = new IrcUserCollection(this, this.users); this.listedChannels = new List<IrcChannelInfo>(); this.listedServerLinks = new List<IrcServerInfo>(); this.listedStatsEntries = new List<IrcServerStatisticalEntry>(); }
public void Connect(string server, int port, string nick, string password = "") { try { Channels = new IrcChannelCollection(); irc = new TcpClient(server, port); ns = irc.GetStream(); sr = new StreamReader(ns); sw = new StreamWriter(ns) { NewLine = "\r\n", AutoFlush = true }; SendCommand("USER " + nick + " +mode * :" + nick); SendCommand("NICK " + nick); this.nick = nick; this.server = server; if (password != "") { SendCommand("IDENTIFY " + password); } connected = true; #region Data Reciever new Thread((ThreadStart) delegate { while (Connected) { string s = sr.ReadLine(); if (s.Trim() != "" && s != null) { DataRecieved(this, new IrcDataEventArgs(s.Trim())); } } }).Start(); #endregion #region Ping Sender new Thread((ThreadStart) delegate { while (Connected) { sw.WriteLine("PING " + server); Thread.Sleep(15000); } }).Start(); #endregion } catch (Exception ex) { connected = false; Console.WriteLine(ex.ToString().Replace(Environment.NewLine, " ")); Thread.Sleep(10000); Connect(server, port, nick, password); } }