internal Connection(ConnectionSettings settings, Action<IRCQEvent> enqueuer) { IrcAuthenticated = false; _settings = settings; Enqueue = enqueuer; Entities = new EntityManager(_settings.DefaultNick); _connectorThread = new Thread(() => { try { Connect(); } catch (Exception ex) { if (ex is ThreadAbortException) throw; else Disconnect(ServerStatus.ConnectFailed, ex.GetType().Name + ": " + ex.Message); } }); _connectorThread.Start(); }
private static ConnectionSettings LoadServerConfig() { ConnectionSettings settings = new ConnectionSettings(); try { Config = new Configuration("settings.txt"); } catch (FileNotFoundException) { SaveServerConfig(); } settings.ServerAddress = Config["Server"]; Out("Configuration", "Server = " + Config["Server"]); string port = Config["Port"]; if (port.StartsWith("++")) { settings.UseSSLVerification = true; port = port.Substring(1); } if (port.StartsWith("+")) { settings.UseSSL = true; port = port.Substring(1); } settings.ServerPort = int.Parse(port); Out("Configuration", "Port = " + Config["Port"]); settings.ServerPassword = Config["ServerPw"]; Out("Configuration", "ServerPw = " + Config["ServerPw"]); settings.DefaultNick = Config["Nick"]; Out("Configuration", "Nick = " + Config["Nick"]); settings.Ident = Config["Ident"]; Out("Configuration", "Ident = " + Config["Ident"]); settings.Realname = Config["RealName"]; Out("Configuration", "RealName = " + Config["RealName"]); IPAddress bindaddr; if (IPAddress.TryParse(Config["Bind"], out bindaddr)) { settings.BindAddress = bindaddr; Out("Configuration", "Bind = " + bindaddr.ToString()); } return settings; }
/// <summary> /// Creates a new instance of IRCQueue. /// </summary> public IrcClient() { _settings = new ConnectionSettings(); _queue = new IRCQueue(this); }