示例#1
0
        public void Connect(string hostname, int port, int connectionTimeout, string nickname, string username, string realname)
        {
            ConnectionFailure = null;
            if (IsConnected)
            {
                Disconnect();
            }

            Hostname          = hostname;
            Port              = port;
            ConnectionTimeout = connectionTimeout;
            Nickname          = nickname;
            Username          = username;
            Realname          = realname;

            thread = new Thread(() =>
            {
                try
                {
                    ConnectionState = IrcConnectionState.Connecting;
                    LocalUser       = new IrcClientUser(this);
                    connection      = new IrcConnection();
                    OnConnecting();
                    connection.Connect(hostname, port, connectionTimeout);
                    ConnectionState = IrcConnectionState.Connected;
                    OnConnect();
                    SetNickname(nickname);
                    SetUser(username, realname);
                    ProcessLines();
                }
                catch (Exception e)
                {
                    Log.Write("irc", e.ToString());
                    if (e is SocketException || e is IOException)
                    {
                        ConnectionFailure = e;
                    }
                }
                finally
                {
                    Disconnect();
                }
            })
            {
                IsBackground = true
            };
            thread.Start();
        }
示例#2
0
        public void Disconnect()
        {
            if (!IsConnected || IsReconnecting)
            {
                ConnectionState = IrcConnectionState.Disconnected;
                return;
            }

            ConnectionState = IrcConnectionState.Disconnecting;
            OnDisconnecting();
            connection.Close();
            ConnectionState = IrcConnectionState.Disconnected;
            OnDisconnect();
            LocalUser  = null;
            connection = null;
        }
示例#3
0
		public void Disconnect()
		{
			if (!IsConnected || IsReconnecting)
			{
				ConnectionState = IrcConnectionState.Disconnected;
				return;
			}

			ConnectionState = IrcConnectionState.Disconnecting;
			OnDisconnecting();
			connection.Close();
			ConnectionState = IrcConnectionState.Disconnected;
			OnDisconnect();
			LocalUser = null;
			connection = null;
		}
示例#4
0
		public void Connect(string hostname, int port, int connectionTimeout, string nickname, string username, string realname)
		{
			ConnectionFailure = null;
			if (IsConnected)
				Disconnect();

			Hostname = hostname;
			Port = port;
			ConnectionTimeout = connectionTimeout;
			Nickname = nickname;
			Username = username;
			Realname = realname;

			thread = new Thread(() =>
			{
				try
				{
					ConnectionState = IrcConnectionState.Connecting;
					LocalUser = new IrcClientUser(this);
					connection = new IrcConnection();
					OnConnecting();
					connection.Connect(hostname, port, connectionTimeout);
					ConnectionState = IrcConnectionState.Connected;
					OnConnect();
					SetNickname(nickname);
					SetUser(username, realname);
					ProcessLines();
				}
				catch (Exception e)
				{
					Log.Write("irc", e.ToString());
					if (e is SocketException || e is IOException)
						ConnectionFailure = e;
				}
				finally
				{
					Disconnect();
				}
			}) { IsBackground = true };
			thread.Start();
		}