Connect() public method

Connects asynchronously to the specified server.
/// is . /// /// does not specify valid registration /// information. /// The current instance has already been disposed.
public Connect ( EndPoint remoteEndPoint, bool useSsl, IrcRegistrationInfo registrationInfo ) : void
remoteEndPoint System.Net.EndPoint /// The network endpoint (IP address and port) of the server to which to connect. ///
useSsl bool /// to connect to the server via SSL; , /// otherwise ///
registrationInfo IrcRegistrationInfo /// The information used for registering the client. /// The type of the object may be either or /// . ///
return void
Beispiel #1
0
        public override void JoinServer(string server, string nickName, string userName, string realName, string password)
        {
            ServerInfo.Server = server;
            ServerInfo.NickName = nickName;
            ServerInfo.UserName = userName;
            ServerInfo.RealName = realName;
            ServerInfo.Password = password;

            Client = new StandardIrcClient();
            Client.Connected += Client_Connected;
            Client.Disconnected += Client_Disconnected;
            Client.Registered += Client_Registered;
            Client.RawMessageReceived += Client_RawMessageReceived;

            var ri = new IrcUserRegistrationInfo();
            ri.NickName = nickName;
            ri.UserName = userName;
            ri.RealName = realName;
            ri.Password = password;

            using (var connectedEvent = new ManualResetEventSlim(false))
            {
                Client.Connected += (sender2, e2) => connectedEvent.Set();
                Client.Connect(server, false, ri);
                if (!connectedEvent.Wait(10000))
                {
                    Client.Dispose();
                    return;
                }
            }
        }
Beispiel #2
0
        protected void Connect(string server, IrcRegistrationInfo registrationInfo)
        {
            // Create new IRC client and connect to given server.
            var client = new StandardIrcClient();

            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);
        }
Beispiel #3
0
        public MainWindow()
        {
            InitializeComponent();
            this.messageField.KeyDown += textBoxEnter;

            //Instantiate an IRC client session
            irc = new StandardIrcClient();
            IrcRegistrationInfo info = new IrcUserRegistrationInfo()
            {
                NickName = Environment.UserName, // "NerdChat",
                UserName = Environment.UserName + "NerdChat",
                RealName = "NerdChat"
            };

            //Open IRC client connection
            irc.Connect("irc.freenode.net", false, info);
            irc.RawMessageReceived += IrcClient_Receive;

            // Add server to treeview
            TreeViewItem serverTreeItem = new TreeViewItem();
            serverTreeItem.Header = "irc.freenode.net";
            channelTree.Items.Add(serverTreeItem);

            // Add some dummy channels for testing
            for (int i = 0; i < 10; i++) {
                TreeViewItem dummyItem = new TreeViewItem();
                dummyItem.Header = "#dummy" + i;
                serverTreeItem.Items.Add(dummyItem);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Called when the "Download" button is clicked.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void Download_Button_Click(object sender, RoutedEventArgs e)
        {
            if (downloading)
            {
                MessageBox.Show("Already in the process of downloading.");
                return;
            }

            // Check that the necessary settings have been filled out
            if (ShowCollection.Count == 0)
            {
                MessageBox.Show("Add some shows first!");
                return;
            }
            if (settings.Nick == "")
            {
                MessageBox.Show("Please enter a nickname in the settings menu.");
                return;
            }
            if (!Directory.Exists(settings.DownloadsFolder))
            {
                MessageBox.Show("Please enter a valid folder to download to in the settings menu.");
                return;
            }

            // Refresh show statuses in case we had an error last time.
            foreach (Show s in ShowCollection)
            {
                UpdateShowStatus(s);
            }

            // If we're already connected, go ahead and start searching for packs
            if (client.IsConnected)
            {
                DownloadAvailableShows(null, null);
            }
            else
            {
                // Otherwise, hookup the connected event and connect to the server.
                Task.Factory.StartNew(() =>
                {
                    // When the client is connected, start downloading the packs
                    client.Connected -= DownloadAvailableShows;
                    client.Connected += DownloadAvailableShows;

                    // Connect to the server.
                    string nick = settings.Nick;
                    client.Connect(new Uri(settings.Server), new IrcUserRegistrationInfo()
                    {
                        NickName = nick, RealName = nick, UserName = nick
                    });
                });
            }
        }
Beispiel #5
0
        protected void Connect(string server, IrcRegistrationInfo registrationInfo)
        {
            // Create new IRC client and connect to given server.
            var client = new StandardIrcClient();
            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);
        }
Beispiel #6
0
        static void Main()
        {
            Logger.Init();

              var server = "irc.rizon.sexy";
              var username = "******";

              using (var client = new StandardIrcClient()) {
            //client.FloodPreventer = new IrcStandardFloodPreventer(4, 2000);
            client.Disconnected += IrcClient_Disconnected;
            client.Registered += IrcClient_Registered;
            // Wait until connection has succeeded or timed out.
            using (var registeredEvent = new ManualResetEventSlim(false)) {
              using (var connectedEvent = new ManualResetEventSlim(false)) {
            client.Connected += (sender2, e2) => connectedEvent.Set();
            client.Registered += (sender2, e2) => registeredEvent.Set();
            client.Connect(server, 6667, false,
                new IrcUserRegistrationInfo() {
                  NickName = username,
                  UserName = username,
                  RealName = username,
                  Password = PrivateConstants.IrcFloodBypassPassword,
                });
            if (!connectedEvent.Wait(10000)) {
              Console.WriteLine($"Connection to '{server}' timed out.");
              return;
            }
              }
              client.LocalUser.NoticeReceived += IrcClient_LocalUser_NoticeReceived;

              Console.Out.WriteLine($"Now connected to '{server}'.");
              if (!registeredEvent.Wait(10000)) {
            Console.WriteLine($"Could not register to '{server}'.");
            return;
              }
            }

            Console.Out.WriteLine($"Now registered to '{server}' as '{username}'.");
            client.Channels.Join(EchoChannel);

            HandleEventLoop(client);
              }
        }
Beispiel #7
0
        public async void Connect()
        {
            client = new StandardIrcClient();

            client.ChannelListReceived += Client_ChannelListReceived;
            client.Connected += Client_Connected;
            client.ConnectFailed += Client_ConnectFailed;
            client.Disconnected += Client_Disconnected;
            client.Error += Client_Error;
            client.ErrorMessageReceived += Client_ErrorMessageReceived;
            client.MotdReceived += Client_MotdReceived;
            client.ProtocolError += Client_ProtocolError;
            client.RawMessageReceived += Client_RawMessageReceived;
            client.Registered += Client_Registered;
            client.ServerBounce += Client_ServerBounce;
            client.ServerLinksListReceived += Client_ServerLinksListReceived;
            client.ServerStatsReceived += Client_ServerStatsReceived;
            client.ServerTimeReceived += Client_ServerTimeReceived;
            client.ServerVersionInfoReceived += Client_ServerVersionInfoReceived;
            client.WhoIsReplyReceived += Client_WhoIsReplyReceived;
            client.WhoReplyReceived += Client_WhoReplyReceived;
            client.WhoWasReplyReceived += Client_WhoWasReplyReceived;

            connection.AddHistory(HtmlWriter.Write(string.Format(MainPage.GetInfoString("TryToConnect"),
                connection.Name, connection.Port == null ? IrcClient.DefaultPort : (int)connection.Port)));
            if (string.IsNullOrWhiteSpace(connection.Nickname))
                connection.Nickname = App.APPNAME + new Random().Next(int.MinValue, int.MaxValue);
            if (string.IsNullOrWhiteSpace(connection.RealName))
                connection.RealName = connection.Nickname;
            client.Connect(connection.Name, connection.Port == null ? IrcClient.DefaultPort : (int)connection.Port,
                false, new IrcUserRegistrationInfo()
                {
                    NickName = connection.Nickname,
                    Password = string.IsNullOrWhiteSpace(connection.Password) ? null : await Encryption.UnProtect(connection.Password),
                    RealName = connection.RealName,
                    UserModes = connection.UserModes,
                    UserName = App.APPNAME
                });
        }