/// <summary> /// Constractor. /// </summary> /// <param name="imageServer">The image server .</param> /// <param name="client"> The tcp client. </param> /// <param name="m_controller"> The image controller.</param> public HandleSettings(ImageServer imageServer, TcpClient client, IImageController m_controller) { imageServer.writeSocket(imageServer.AppConfigText(), client); NetworkStream ns = client.GetStream(); //string r = imageServer.readSocket(ns); if (client.Connected) { while (true) { string command = imageServer.readSocket(ns); string[] split = command.Split('$'); int id = 0; bool t = true; if (split[0] == "Exit Server") { break; } if (split[0] == "CloseCommand") { id = (int)CommandEnum.CloseCommand; imageServer.delete_handler(split[1]); m_controller.ExecuteCommand(id, split, out t); } if (split[0] == "Exit Server") { break; } if (!client.Connected) { break; } if (!client.Connected) { break; } } } }
/// <summary> /// Function that send log to client. /// </summary> /// <param name="g"> Message of the log. </param> public void SendLog(MessageRecievedEventArgs g) { try { //send all the new messages. foreach (MessageRecievedEventArgs m in path_list.ToList()) { if (!sended_logs.Contains(m)) { string b = m.Message; string c = m.Status.ToString(); string f = "$"; string colour = ""; if (c == "INFO") { colour = "Green"; } if (c == "ERROR") { colour = "Red"; } if (c == "WARNING") { colour = "Yello"; } imageServer.writeSocket("colour=" + colour + f + "log=" + c + f + "message=" + b + f, tCP); sended_logs.Add(m); } } } catch (Exception e) { } }
/// <summary> /// Set function. /// </summary> /// <param name="imageServer1">The image server.</param> /// <param name="loggingService1">The logging service.</param> /// <param name="tCP1">The tcp network stream.</param> public void SetAllProt(ImageServer imageServer1, ILoggingService loggingService1, TcpClient tCP1) { this.tCP = tCP1; this.imageServer = imageServer1; this.loggingService = loggingService1; sended_logs = new ObservableCollection <MessageRecievedEventArgs>(); ListLogg = loggingService.listOfLoggins(); ListLogg.CollectionChanged += collectionChange; //add all the logs message to the application. //send it by seperate by $. foreach (MessageRecievedEventArgs m in path_list.ToList()) { string b = m.Message; string c = m.Status.ToString(); string g = "$"; string colour = ""; if (c == "INFO") { colour = "Green"; } if (c == "ERROR") { colour = "Red"; } if (c == "WARNING") { colour = "Yello"; } imageServer.writeSocket("colour=" + colour + g + "log=" + c + g + "message=" + b + g, tCP1); i++; sended_logs.Add(m); } }