private void SocketClient_OnClosingSocket(object sender, DataHoldingEventArgs e) { lock (this.ConnectedServerInfo) { this.ConnectedServerInfo.Remove(this.ConnectedServerInfo.First(t => t.TokenId == e.DataHoldingUserToken.TokenId)); } }
private static void SocketClient_OnStartingSend(object sender, DataHoldingEventArgs e) { DataHolder dataHolder = e.DataHoldingUserToken.DataHolder as DataHolder; Console.WriteLine($"{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")}- 以 Token ID: {e.DataHoldingUserToken.TokenId} 準備送資料給伺服器端({e.DataHoldingUserToken.RemoteEndpoint})。"); Console.WriteLine($" 資料:{System.Text.Encoding.UTF8.GetString(dataHolder.OriginalDataToSend) }"); Console.WriteLine($" (已處理)資料:{String.Join(" ", dataHolder.Data) }"); }
private static void SocketClient_OnClosingSocket(object sender, DataHoldingEventArgs e) { Console.WriteLine($"{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")}- 客戶端正在關閉 Socket ,Token ID:\"{e.DataHoldingUserToken.TokenId}\""); }
private static void SocketClient_OnReceivedMessage(object sender, DataHoldingEventArgs e) { Console.WriteLine($"{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")}- 已完成一次 Receive 作業,目前結果: {(e.DataHoldingUserToken.DataHolder.Data == null ? "尚未建立或已傳送完畢" : System.Text.Encoding.UTF8.GetString(e.DataHoldingUserToken.DataHolder.Data))}"); }
private static void SocketClient_OnReceiveEmptyData(object sender, DataHoldingEventArgs e) { Console.WriteLine($"{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")}- 接收到空白資料,Token ID: {e.DataHoldingUserToken.TokenId}"); }
private static void SocketClient_OnSendCompleted(object sender, DataHoldingEventArgs e) { Console.WriteLine($"{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")}- Send 操作已完成,Token ID: {e.DataHoldingUserToken.TokenId}"); }
private static void SocketClient_OnDataSent(object sender, DataHoldingEventArgs e) { Console.WriteLine($"{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")}- 已傳送完整訊息,Token ID: {e.DataHoldingUserToken.TokenId},訊息: { System.Text.Encoding.UTF8.GetString(e.DataHoldingUserToken.DataHolder.Data)}"); }
private static void SocketClient_OnStartingReceive(object sender, DataHoldingEventArgs e) { Console.WriteLine($"{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")}- 以 Token ID: {e.DataHoldingUserToken.TokenId} 準備接受伺服器端({e.DataHoldingUserToken.RemoteEndpoint})的資料。"); }