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 RemovePasswordsOfClients(List <int> clients)
        {
            _tcpServerInfo.DatabaseManager.RemovePasswords(clients);

            var writerCall = new WriterCall(new Serializer(typeof(List <int>)).Serialize(clients));

            foreach (var administration in _tcpServerInfo.Administrations)
            {
                administration.Value.SendPackage((byte)FromClientPackage.PasswordsRemoved, writerCall);
            }
        }
Ejemplo n.º 5
0
        public void RemoveDataEntries(List <int> removedDataIds)
        {
            _tcpServerInfo.DatabaseManager.RemoveDataEntries(removedDataIds);

            var writerCall = new WriterCall(new Serializer(typeof(List <int>)).Serialize(removedDataIds));

            foreach (var administration in _tcpServerInfo.Administrations)
            {
                administration.Value.SendPackage((byte)FromClientPackage.DataRemoved, writerCall);
            }
        }
Ejemplo n.º 6
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.º 7
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.º 8
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.º 9
0
        public async Task UnsafeSendCommand(Command command, WriterCall writerCall)
        {
            if (command.Identifier > 1000)
            {
                if (!await PreparePlugin(command.Identifier))
                {
                    return;
                }
            }

            Sender.UnsafeSendCommand(ClientInformation.Id, command.Identifier, writerCall);

            PackageSent?.Invoke(this, new PackageInformation
            {
                Description = $"UnsafeSendCommand ({command} / ID: {command.Identifier})",
                IsReceived  = false,
                Size        = writerCall.Size,
                Timestamp   = DateTime.Now
            });
        }
 public SendPackageToClientEventArgs(int clientId, byte command, WriterCall writerCall)
     : base(command, writerCall)
 {
     ClientId = clientId;
 }
Ejemplo n.º 11
0
 public void SendStream(WriterCall writerCall)
 {
     throw new NotSupportedException();
 }
 public SendPackageToAdministrationEventArgs(ushort administrationId, byte command, WriterCall writerCall)
     : base(command, writerCall)
 {
     AdministrationId = administrationId;
 }
Ejemplo n.º 13
0
 public void SendStream(WriterCall writerCall)
 {
     _binaryWriter.Write(writerCall.Size);
     writerCall.WriteIntoStream(_networkStream);
 }
 public void SendStream(WriterCall writerCall)
 {
     throw new NotImplementedException();
 }
 public SendPackageEventArgs(byte command, WriterCall writerCall)
 {
     Command    = command;
     WriterCall = writerCall;
 }
Ejemplo n.º 16
0
 public void UnsafeSendCommand(int clientId, uint commandId, WriterCall writerCall)
 {
 }
Ejemplo n.º 17
0
 public void UnsafeResponse(Command command, WriterCall writerCall)
 {
 }