private void SendTask() { while (client != null && client.Connected) { BinaryObj binObj = null; try { if (sendQueue.TryDequeue(out binObj)) { stream.Write(binObj.bytes, 0, binObj.length); rps++; //stream.Flush(); } } catch (OperationCanceledException) { } catch (Exception e) { LogError?.Invoke(e.ToString()); } finally { if (binObj != null) { binObj.ResetOjb(); BinaryObjPool.Checkin(binObj); } } } LogInfo?.Invoke("SimpleTcpClient SendTask shutdown"); }
private void SendTask() { while (socket != null && socket.Connected) { BinaryObj binObj = null; try { if (sendQueue.TryDequeue(out binObj)) { socket.Send(binObj.bytes, 0, binObj.length, SocketFlags.None); } } catch (OperationCanceledException) { } catch (Exception e) { LogError?.Invoke(e.ToString()); } finally { if (binObj != null) { binObj.ResetOjb(); BinaryObjPool.Checkin(binObj); } } } LogInfo?.Invoke("SimpleTcpClient SendTask shutdown"); }
public static void Checkin(BinaryObj binObj) { binObj.ResetOjb(); if (binObj.type == BinaryObj.PresetType.RequestToMatching) { PoolForReq.Pool.Checkin(binObj); } else if (binObj.type == BinaryObj.PresetType.ProcessOrderResult) { PoolForResp.Pool.Checkin(binObj); } else if (binObj.type == BinaryObj.PresetType.Transaction) { PoolForTx.Pool.Checkin(binObj); } }