示例#1
0
 public void WriteCommands()
 {
     if (this.IsConnected && this.socket.CanWrite)
     {
         while (true)
         {
             MemoryStreamData data;
             while (true)
             {
                 if (this.packetQueue.Count != 0)
                 {
                     CommandPacket packet = this.packetQueue.Dequeue();
                     try
                     {
                         data = this.protocolAdapter.Encode(packet);
                         break;
                     }
                     catch (Exception exception)
                     {
                         this.log.DebugFormat("OnSocketProblem {0}", exception.Message);
                         this.OnSocketProblem(ProblemStatus.EncodeError, exception);
                     }
                     finally
                     {
                         ClientNetworkInstancesCache.ReleaseCommandPacketWithCommandsCollection(packet);
                     }
                     return;
                 }
                 else
                 {
                     return;
                 }
                 break;
             }
             try
             {
                 if (this.infoEnabled)
                 {
                     this.log.DebugFormat("WriteCommands {0}", data.Length);
                 }
                 this.socket.Write(data.GetBuffer(), 0, (int)data.Length);
             }
             catch (IOException exception2)
             {
                 this.OnSocketProblem(ProblemStatus.SendError, exception2);
             }
             finally
             {
                 ClientProtocolInstancesCache.ReleaseMemoryStreamData(data);
             }
         }
     }
 }
 public void FinalizeDecodedCommandPacket(CommandPacket commandPacket)
 {
     ClientNetworkInstancesCache.ReleaseCommandPacketWithCommandsCollection(commandPacket);
 }