Beispiel #1
0
        public void ConnectTo(Server toServer, Credentials credentials)
        {
            this.server = toServer;

            string inputLine;

            try
            {
                var serverConnectionStarted = new ServerConnectionStarted {
                    ServerConnection = this
                };
                eventAggregator.Raise(serverConnectionStarted);

                irc    = new TcpClient(toServer.Address, toServer.Port);
                stream = irc.GetStream();
                reader = new StreamReader(stream, Encoding.Default);
                writer = new StreamWriter(stream);

                var serverAddress = toServer.Address;

                ping = new PingSender(ref writer, ref serverAddress);
                ping.Start();

                SendCredentials(credentials);

                // Odotetaan viestejä
                while ((inputLine = reader.ReadLine()) != null)
                {
                    ProcessIncomingMessage(inputLine);
                }

                // Suljetaan streamit
                writer.Close();
                reader.Close();
                irc.Close();
            }
            catch (Exception e)
            {
                Thread.Sleep(1000);
            }
        }
Beispiel #2
0
        public void ConnectTo(Server toServer, Credentials credentials)
        {
            this.server = toServer;

            string inputLine;
            try
            {
                var serverConnectionStarted = new ServerConnectionStarted {ServerConnection = this};
                eventAggregator.Raise(serverConnectionStarted);

                irc = new TcpClient(toServer.Address, toServer.Port);
                stream = irc.GetStream();
                reader = new StreamReader(stream, Encoding.Default);
                writer = new StreamWriter(stream);

                var serverAddress = toServer.Address;

                ping = new PingSender(ref writer, ref serverAddress);
                ping.Start();

                SendCredentials(credentials);

                // Odotetaan viestejä
                while ((inputLine = reader.ReadLine()) != null)
                {
                    ProcessIncomingMessage(inputLine);
                }

                // Suljetaan streamit
                writer.Close();
                reader.Close();
                irc.Close();

            }
            catch (Exception e)
            {
                Thread.Sleep(1000);
            }
        }