예제 #1
0
 // 处理消息发送事件
 static void client_MessageSended(object sender, CSSL3SocketServer.SocketMessageEventArgs e)
 {
     if (e.Error != null)
     {
         Console.WriteLine("消息发送失败: " + e.Error.Message);
         ((SocketClient)sender).Close();
         Console.WriteLine("客户端断开连接。");
     }
     else
     {
         Console.WriteLine("消息发送成功!");
     }
 }
예제 #2
0
파일: Program.cs 프로젝트: thexur/1code
 // Handle message sended event
 static void client_MessageSended(object sender, CSSL3SocketServer.SocketMessageEventArgs e)
 {
     if (e.Error != null)
     {
         Console.WriteLine("Message send failed: " + e.Error.Message);
         ((SocketClient)sender).Close();
         Console.WriteLine("Client disconnected.");
     }
     else
     {
         Console.WriteLine("Message send successful");
     }
 }
예제 #3
0
 // 处理消息接收事件
 static void client_MessageReceived(object sender, CSSL3SocketServer.SocketMessageEventArgs e)
 {
     if (e.Error != null)
     {
         Console.WriteLine("消息接收失败: " + e.Error.Message);
         ((SocketClient)sender).Close();
         Console.WriteLine("客户端断开连接。");
     }
     else
     {
         // 等待1秒后,回发消息
         Console.WriteLine("收到消息: " + e.Data);
         Thread.Sleep(1000);
         SendMessage(sender as SocketClient,
                     "处理: " + e.Data);
     }
 }
예제 #4
0
파일: Program.cs 프로젝트: thexur/1code
 // Handle message received event
 static void client_MessageReceived(object sender, CSSL3SocketServer.SocketMessageEventArgs e)
 {
     if (e.Error != null)
     {
         Console.WriteLine("Message receive failed: " + e.Error.Message);
         ((SocketClient)sender).Close();
         Console.WriteLine("Client disconnected.");
     }
     else
     {
         // Idle 1 second and send message back
         Console.WriteLine("Message Received: " + e.Data);
         Thread.Sleep(1000);
         SendMessage(sender as SocketClient,
                     "Handled: " + e.Data);
     }
 }