Beispiel #1
0
        /// <summary>
        /// Establishing server connection. Makes also first validation and check if all required
        /// parameters are set.
        /// </summary>
        private void Connect()
        {
            SendLine += new LineHandler(WriteContext);

            try {
                socket = new TcpClient(this.host, this.port);
                Connected(new EventArgs());
            } catch(Exception e) {
                throw new IOException(e.Message);
            }
            try {
                stream = socket.GetStream();
                readingThread = new Thread(new ThreadStart(ReadContext));
                readingThread.IsBackground = true;
                readingThread.Name = "reading thread";
                readingThread.Start();

                AbstractCommand uc;
                if(string.IsNullOrEmpty(this.RealName) || string.IsNullOrEmpty(Username) || string.IsNullOrEmpty(this.Mode))
                    throw new NoParameterException("Real name or Username or mode");
                uc = new UserCommand(this.Username, this.Mode, this.RealName);
                SendLine(uc.execute());

                uc = new NickCommand() {
                    Nick = this.Nick
                };
                if(string.IsNullOrEmpty(this.Nick))
                    throw new NoParameterException("Nick");

                SendLine(uc.execute());

            #if DEBUG
                uc = new JoinCommand() {
                    Name = "interia"
                };
                SendLine(uc.execute());
            #endif

            } catch(Exception ex) {
                throw ex;
            }
        }
Beispiel #2
0
 /// <summary>
 /// Joins channel
 /// </summary>
 /// <param name="channelName"> channel name w/o #</param>
 public void JoinChannel(string channelName)
 {
     AbstractCommand command = new JoinCommand() {
         Name = channelName
     };
     SendLine(command.execute());
 }