/// <summary> /// The function sending to the tcp the command of closed handler to notify all clients /// </summary> /// <param name="dirPath"> dirPath of folder to remove </param> private void RemoveHandlerFromClients(string dirPath) { MessageCommand mc = new MessageCommand(); mc.CommandID = (int)CommandEnum.CloseCommand; mc.CommandMsg = dirPath; m_tcpServer.SendAll(mc.ToJSON()); }
/// <summary> /// Sends the remove dir. /// </summary> /// <param name="dir">The dir.</param> public void SendRemoveDir(string dir) { MessageCommand mc = new MessageCommand(); mc.CommandID = (int)CommandEnum.CloseCommand; mc.CommandMsg = dir; communicationHandler.Client.Send(mc.ToJSON()); }
public ActionResult DeleteHandler() { MessageCommand mc = new MessageCommand(); mc.CommandID = (int)CommandEnum.CloseCommand; mc.CommandMsg = m_directory; m_communication.Client.Send(mc.ToJSON()); m_settingsModel.SettingsRequest(); return(RedirectToAction("Settings")); }
private void NewLogEntry(object sender, MessageRecievedEventArgs messageArgs) { MessageCommand mc = new MessageCommand(); mc.CommandID = (int)CommandEnum.LogCommand; List <string> log = new List <string>(); log.Add((messageArgs.Status as Enum).ToString() + ";" + messageArgs.Message); mc.CommandMsg = JsonConvert.SerializeObject(log); m_tcpServer.SendAll(mc.ToJSON()); }
/// <summary> /// C'tor /// </summary> public LogModel() { m_logEntries = new ObservableCollection <MessageRecievedEventArgs>(); m_commands = new Dictionary <int, CommandExecute> { { (int)CommandEnum.LogCommand, SetLogEntries } }; communicationHandler = ModelCommunicationHandler.Instance; communicationHandler.DataReceived += GetCommand; MessageCommand mc = new MessageCommand(); mc.CommandID = (int)CommandEnum.LogCommand; mc.CommandMsg = ""; communicationHandler.Client.Send(mc.ToJSON()); Thread.Sleep(100); }
private void DataReceviedServer(object sender, DataReceivedEventArgs e) { MessageCommand mc = MessageCommand.FromJSON(e.Message); if (mc.CommandID == (int)CommandEnum.CloseCommand) { CommandRecievedEventArgs comArgs = new CommandRecievedEventArgs((int)CommandEnum.CloseCommand, null, mc.CommandMsg); CommandRecieved?.Invoke(this, comArgs); } else { string convert = m_controller.ExecuteCommand(mc.CommandID, null, out bool result); mc.CommandMsg = convert; ClientHandler ch = sender as ClientHandler; ch.Send(mc.ToJSON()); } }
/// <summary> /// C'tor. /// </summary> public SettingsModel() { // need to remove this m_commands = new Dictionary <int, CommandExecute> { { (int)CommandEnum.GetConfigCommand, SetConfigSettings }, { (int)CommandEnum.CloseCommand, RemoveDir } }; communicationHandler = ModelCommunicationHandler.Instance; communicationHandler.DataReceived += GetCommand; MessageCommand mc = new MessageCommand(); mc.CommandID = (int)CommandEnum.GetConfigCommand; mc.CommandMsg = ""; communicationHandler.Client.Send(mc.ToJSON()); Thread.Sleep(1000); }