void Server_OnDataSended(object sender, SslTcpEventArgs e) { WriteLog("送出資料 {0} Bytes", e.Data.Length); if (chkHexString.Checked) { WriteLog("Hex:{0}", e.Data.ToHexString()); } else { WriteLog(" > :{0}", Encoding.Default.GetString(e.Data)); } }
/// <summary>產生 AuthenticateFail 事件</summary> /// <param name="ep">已連線的 System.Net.EndPoint 類別。</param> protected virtual void OnAuthenticateFail(EndPoint ep) { if (this.AuthenticateFail != null) { SslTcpEventArgs ea = new SslTcpEventArgs(ep); foreach (EventHandler <SslTcpEventArgs> del in this.AuthenticateFail.GetInvocationList()) { try { del.BeginInvoke(this, ea, null, null); } catch { } } } }
/// <summary>產生 DataSendFail 事件</summary> /// <param name="ep">遠端使用者的 System.Net.EndPoint 類別。</param> /// <param name="data">發送失敗的資料內容。</param> protected virtual void OnDataSendFail(EndPoint ep, byte[] data) { if (this.DataSendFail != null) { SslTcpEventArgs ea = new SslTcpEventArgs(ep, data); foreach (EventHandler <SslTcpEventArgs> del in this.DataSendFail.GetInvocationList()) { try { del.BeginInvoke(this, ea, null, null); } catch { } } } }
void Server_OnDataReceived(object sender, SslTcpEventArgs e) { string data = Encoding.UTF8.GetString(e.Data); WriteLog("自 {0} 收到資料, {1} Bytes", e.RemoteEndPoint, e.Data.Length); if (chkHexString.Checked) { WriteLog("Hex:{0}", e.Data.ToHexString()); } else { WriteLog(" > :{0}", data); } }
void Server_OnClientConnected(object sender, SslTcpEventArgs e) { WriteLog("用戶端 {0} 已連線", e.RemoteEndPoint); }
void Server_AuthenticateFail(object sender, SslTcpEventArgs e) { WriteLog("用戶端 {0} 認證失敗", e.RemoteEndPoint); }
void Client_AuthenticateFail(object sender, SslTcpEventArgs e) { WriteLog("與伺服器 {0} 認證失敗", e.RemoteEndPoint); btnStop_Click(null, null); }
void Client_OnConnected(object sender, SslTcpEventArgs e) { WriteLog("已與伺服器 {0} 連線", e.RemoteEndPoint); }