Ejemplo n.º 1
0
        public void UnsafeResponse(Command command, WriterCall writerCall)
        {
            if (_isFailed)
            {
                return;
            }

            lock (_sendLock)
            {
                try
                {
                    ServerConnection.BinaryWriter.Write((byte)FromClientPackage.ResponseToAdministration);

                    ServerConnection.BinaryWriter.Write(writerCall.Size + 7);
                    //1 for the responseType and 2 for the ushort
                    ServerConnection.BinaryWriter.Write(BitConverter.GetBytes(AdministrationId));
                    ServerConnection.BinaryWriter.Write((byte)ResponseType.CommandResponse);
                    ServerConnection.BinaryWriter.Write(BitConverter.GetBytes(command.Identifier));
                    writerCall.WriteIntoStream(ServerConnection.BinaryWriter.BaseStream);
                    ServerConnection.BinaryWriter.Flush();
                }
                catch (Exception)
                {
                    OnFailed();
                }
            }
        }
Ejemplo n.º 2
0
 public void SendStream(WriterCall writerCall)
 {
     _connectionInfo.UnsafeResponse(_command, new WriterCall(writerCall.Size + 1, stream =>
     {
         stream.WriteByte(_prefix);
         writerCall.WriteIntoStream(stream);
     }));
 }
Ejemplo n.º 3
0
 public Task UnsafeSendCommand(Command command, WriterCall writerCall)
 {
     using (var memoryStream = new MemoryStream(writerCall.Size))
     {
         writerCall.WriteIntoStream(memoryStream);
         return(SendCommand(command, memoryStream.ToArray()));
     }
 }
Ejemplo n.º 4
0
 public void SendPackage(byte command, WriterCall writerCall)
 {
     try
     {
         lock (_sendLock)
         {
             _binaryWriter.Write(command);
             _binaryWriter.Write(writerCall.Size);
             writerCall.WriteIntoStream(_sslStream);
         }
     }
     catch (Exception ex)
     {
         ReportError(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
     }
 }
Ejemplo n.º 5
0
 public void SendPackage(byte command, WriterCall writerCall)
 {
     try
     {
         lock (_sendLock)
         {
             Connection.BinaryWriter.Write(command);
             Connection.BinaryWriter.Write(writerCall.Size);
             writerCall.WriteIntoStream(Connection.BaseStream);
         }
     }
     catch (Exception ex)
     {
         ReportError(ex, MethodBase.GetCurrentMethod().Name);
     }
 }
Ejemplo n.º 6
0
 public void UnsafeSendCommand(int clientId, uint commandId, WriterCall writerCall)
 {
     try
     {
         lock (WriterLock)
         {
             Connection.BinaryWriter.Write((byte)FromAdministrationPackage.SendCommand);
             Connection.BinaryWriter.Write(writerCall.Size + 9);
             Connection.BinaryWriter.Write(BitConverter.GetBytes(clientId));
             Connection.BinaryWriter.Write((byte)SendingType.Command);
             Connection.BinaryWriter.Write(BitConverter.GetBytes(commandId));
             writerCall.WriteIntoStream(Connection.BaseStream);
             Connection.BinaryWriter.Flush();
         }
     }
     catch (Exception)
     {
         // ignored
     }
 }
Ejemplo n.º 7
0
 public void SendStream(WriterCall writerCall)
 {
     _binaryWriter.Write(writerCall.Size);
     writerCall.WriteIntoStream(_networkStream);
 }