Ejemplo n.º 1
0
        /// <summary>
        /// 接続
        /// </summary>
        /// <param name="server">サーバーデータ</param>
        /// <param name="user">ユーザーデータ</param>
        public void Connect(ServerInfo server, UserInfo user)
        {
            if (Status != IRCClientStatus.Disconnected)
            {
                throw new InvalidOperationException();
            }

            try
            {
                // 準備。
                m_server = server;
                m_user = user;
                m_online = false;
                m_threadStopFlag = false;
                lock (m_sendQueue) { m_sendQueue.Clear(); }
                lock (m_namelist) { m_namelist.Clear(); }

                // ソケット作成・接続
                Debug.WriteLine("接続を開始します。", "IRCClient");
                m_socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                if (Server.UseSsl)
                {
                    m_sslHelper = new SslHelper(m_socket, Server.Name);
                    m_sslHelper.ValidateCertEnabled = !Server.NoValidation;
                }
                m_connectAsync = m_socket.BeginConnect(server.GetEndPoint(), new AsyncCallback(OnConnected), m_socket);
            }
            catch
            {
                OnConnectionFailed();
                Close();
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 接続
 /// </summary>
 /// <param name="name">サーバー名</param>
 /// <param name="nickname">ニックネーム</param>
 /// <param name="realname">名前</param>
 public void Connect(ServerInfo server, string nickname, string realname)
 {
     Connect(server, new UserInfo(nickname, realname));
 }