Exemplo n.º 1
0
        public ConnectionWorker(IRCServer server)
        {
            this.server = server;
            program     = Program.INSTANCE;
            server.SetWorker(this);
            try
            {
                connection = new TcpClient(server.IP, server.PORT);
                stream     = connection.GetStream();
                if (server.SSL)
                {
                    stream = Protocol.Secure(server, stream);
                }
                Console.WriteLine("Starting " + server.IP);
                this.reader = new StreamReader(stream);
                this.writer = new StreamWriter(stream);


                while (!stream.CanWrite)
                {
                    ;
                }
                this.writer.Write("NICK " + server.Nick + "\r\n");
                this.writer.Write("USER " + server.RealName + " 0 * :" + server.RealName + "\r\n");
                this.writer.Flush();
                Working = true;
            }
            catch (IOException)
            {
                Console.WriteLine("Unable to connect to " + server.IP + ", possibly SSL mismatch or host doesn't exist.");
            }
        }
Exemplo n.º 2
0
        public ConnectionWorker(IRCServer server)
        {
            this.server = server;
            program = Program.INSTANCE;
            server.SetWorker(this);
            try
            {
                connection = new TcpClient(server.IP, server.PORT);
                stream = connection.GetStream();
                if (server.SSL)
                {

                    stream = Protocol.Secure(server, stream);
                }
                Console.WriteLine("Starting " + server.IP);
                this.reader = new StreamReader(stream);
                this.writer = new StreamWriter(stream);

                while (!stream.CanWrite) ;
                this.writer.Write("NICK " + server.Nick + "\r\n");
                this.writer.Write("USER " + server.RealName + " 0 * :" + server.RealName + "\r\n");
                this.writer.Flush();
                Working = true;
            }
            catch (IOException)
            {
                Console.WriteLine("Unable to connect to " + server.IP + ", possibly SSL mismatch or host doesn't exist.");
            }
        }