//接收数据并修改部分数据然后发送回去 void sender_ReceiveData(IDataTransmit sender, NetEventArgs e) { try { byte[] data = (byte[])e.EventArg; //发送数据 sender.Send(data); Log(sender.RemoteEndPoint.ToString() + " 发送数据"); } catch (Exception ex) { Log("处理数据出错:" + ex.Message); } }
//接收数据并修改部分数据然后发送回去 void sender_ReceiveData(IDataTransmit sender, NetEventArgs e) { string result; try { byte[] data = (byte[])e.EventArg; var json = encode.GetString(data); result = CRL.CacheServer.CacheService.Deal(json); } catch (Exception ex) { Log("处理数据出错:" + ex.Message); result = "error,服务器内部错误:" + ex.Message; } //发送数据 var data2 = encode.GetBytes(result); sender.Send(data2); }
//接收数据并修改部分数据然后发送回去 void sender_ReceiveData(IDataTransmit sender, NetEventArgs e) { string result; try { byte[] data = (byte[])e.EventArg; var json = encode.GetString(data); result = CRL.CacheServer.CacheService.Deal(json); } catch (Exception ex) { Log("处理数据出错:" + ex.Message); result = "error,服务器内部错误:" + ex.Message; } //发送数据 var data2 = encode.GetBytes(result); sender.Send(data2); }