protected void Connect(string server, IrcRegistrationInfo registrationInfo) { // Create new IRC client and connect to given server. var client = new IrcClient(); client.FloodPreventer = new IrcStandardFloodPreventer(4, 2000); client.Connected += IrcClient_Connected; client.Disconnected += IrcClient_Disconnected; client.Registered += IrcClient_Registered; // Wait until connection has succeeded or timed out. using (var connectedEvent = new ManualResetEventSlim(false)) { client.Connected += (sender2, e2) => connectedEvent.Set(); client.Connect(server, false, registrationInfo); if (!connectedEvent.Wait(10000)) { client.Dispose(); ConsoleUtilities.WriteError("Connection to '{0}' timed out.", server); return; } } // Add new client to collection. this.allClients.Add(client); Console.Out.WriteLine("Now connected to '{0}'.", server); }
public void Connect(string server, IrcRegistrationInfo registrationInfo) { _ircClient = new StandardIrcClient(); _ircClient.FloodPreventer = new IrcStandardFloodPreventer(4, 2000); _ircClient.Connected += ClientOnConnected; _ircClient.Disconnected += ClientOnDisconnected; _ircClient.Registered += ClientOnRegistered; _ircClient.Connect(server, false, registrationInfo); }
public QaIrc(IrcConfiguration config, IrcRegistrationInfo userInfo, ILogger <QaIrc> logger, QCommandsHandler commandHandler, RelayService relay, IServiceProvider services) { _hostname = config.Connection; _userInfo = userInfo; _logger = logger; _commandHandler = commandHandler; _relay = relay; _relay.DiscordMessageReceived += BounceToIRC; _services = services; _channels = config.Channels; InitializeClient(); }
private void Reconnect() { this.Tooltip = string.Format("twitch: {0}?", _streamerNick); this.Header = "Checking..."; if (_ircClient != null) { _ircClient.Disconnect(); _ircClient = null; } _ircClient = new IrcClient(); //IrcClient. = "TWITCHCLIENT 3"; _ircClient.PongReceived += IrcClient_PongReceived; _ircClient.PingReceived += IrcClient_PingReceived; _ircClient.Connected += IrcClient_Connected; _ircClient.ProtocolError += IrcClient_ProtocolError; _ircClient.Error += IrcClient_Error; _ircClient.Disconnected += IrcClient_Disconnected; _ircClient.RawMessageReceived += IrcClient_RawMessageReceived; _ircClient.ConnectFailed += IrcClient_ConnectFailed; _ircClient.MotdReceived += IrcClient_MotdReceived; //IrcClient. Random rnd = new Random(); string s = "justinfan" + rnd.Next(100000000); _regInfo = new IrcUserRegistrationInfo() { NickName = s, UserName = s, Password = "******", RealName = s }; string[] dat = Main.Properties.Settings.Default.url_Twitch.Split(':'); try { int port = int.Parse(dat[1]); _ircClient.Connect(dat[0], port, false, _regInfo); } catch (Exception e) { StartReconnect(); MessageError("Connection error: " + e.Message); } }
public void Connect(string server, IrcRegistrationInfo registrationInfo) { // Create new IRC client and connect to given server. var client = new IrcClient(); client.FloodPreventer = new IrcStandardFloodPreventer(4, 2000); client.Connected += IrcClient_Connected; client.Disconnected += IrcClient_Disconnected; client.Registered += IrcClient_Registered; // Wait until connection has succeeded or timed out. using (var connectedEvent = new ManualResetEventSlim(false)) { client.Connected += (sender2, e2) => connectedEvent.Set(); client.Connect(server, false, registrationInfo); if (!connectedEvent.Wait(10000)) { client.Dispose(); ConsoleUtilities.WriteError("Connection to '{0}' timed out.", server); return; } } // Add new client to collection. this.allClients.Add(client); Console.Out.WriteLine("Now connected to '{0}'.", server); }