private void SendCommand(ClientCommandDTO clientCommand) { string commandSerialization = JsonConvert.SerializeObject(clientCommand); byte[] commandByteArray = Encoding.ASCII.GetBytes(commandSerialization); _TCPClient.SendDataAsync(commandByteArray); }
private void InitializeSendCommand(ClientCommandDTO clientCommand) { lock (commandQueueLocker) { _sendCommands.Add(new SendCommandInformation(clientCommand)); } }
private void TimerInvoke(object sender) { lock (_timerLocker) { ClientCommandRequest clientCommandRequest = new ClientCommandRequest(); _scheduleCommands.TryGetValue((Timer)sender, out clientCommandRequest); ClientCommandDTO clientCommand = _clientMediator.ProducingClientCommand(clientCommandRequest); _clientMediator.SendClientCommand(clientCommand); } }
public void SendClientCommand(ClientCommandDTO clientCommand) { if (!IsRun) { Run(); } else { _crClient.RecieveUserCommand(clientCommand); } }
private void RecieveClientCommand(byte[] message, IPEndPoint sender) { string clientCommandSerialization = Encoding.ASCII.GetString(message); ClientCommandDTO clientCommand = JsonConvert.DeserializeObject <ClientCommandDTO>(clientCommandSerialization); ServerResponseDTO serverResponse = _serverCommandHandler.HandleCommand(clientCommand); string serverResponseSerialization = JsonConvert.SerializeObject(serverResponse); byte[] serverResponseBytesArray = Encoding.ASCII.GetBytes(serverResponseSerialization); _tcpServer.SendDataAsync(serverResponseBytesArray, sender); }
public ServerResponseDTO HandleCommand(ClientCommandDTO clientCommand) { MethodInfo handleMethod = SearchHandleMethod(_handleclass, clientCommand.Command); if (handleMethod == null) { throw new ServerCommandHandleException("Undefined command"); } ServerResponseInformation serverResponseInformation = (ServerResponseInformation)handleMethod.Invoke(this, new object[] { clientCommand.Information }); return(new ServerResponseDTO { IdCommand = clientCommand.IdCommand, Command = clientCommand.Command, Information = serverResponseInformation }); }
public SendCommandInformation(ClientCommandDTO clientCommand) { Command = clientCommand; SendTime = DateTime.Now; CountResend = 0; }
public void RecieveUserCommand(ClientCommandDTO newClientCommand) { SendCommand(newClientCommand); InitializeSendCommand(newClientCommand); }