/// <summary> /// write message to the channel /// </summary> public void Write(string message) { if (IsConnected) { clientHandler.WriteMessage(message); } }
/// <summary> /// method for handeling message from communication channel /// </summary> /// <param name="sender"></param> /// <param name="message"> received message</param> private void HandleMessageFromServer(object sender, MessageCommunicationEventArgs message) { IClientHandler clientHandler = sender as IClientHandler; ServerClientCommunicationCommand commCommand = ServerClientCommunicationCommand.FromJson(message.Message); switch (commCommand.CommId) { case CommandEnum.GetConfigCommand: //asking for logs list case CommandEnum.LogCommand: bool flag1; string result = this.m_controller.ExecuteCommand(commCommand.CommId, commCommand.Args, out flag1); string[] responseArr1 = new string[1]; responseArr1[0] = result; ServerClientCommunicationCommand responseCommand = new ServerClientCommunicationCommand(commCommand.CommId, responseArr1); string responseJson = responseCommand.ToJson(); //writing back the answer to the client request clientHandler?.WriteMessage(responseJson); break; //closing a directory handler request case CommandEnum.CloseCommand: bool flag2; string pathRemoved = this.m_controller.ExecuteCommand(commCommand.CommId, commCommand.Args, out flag2); //writing to all of the connected clients the path of directory which's handler closed string[] responseArr2 = new string[1]; responseArr2[0] = pathRemoved; this.m_serverChannel.BroadcastToClients(new ServerClientCommunicationCommand(CommandEnum.CloseCommand, responseArr2)); break; case CommandEnum.PhotoTransferCommand: bool flag3; string temp = this.m_controller.ExecuteCommand(commCommand.CommId, commCommand.Args, out flag3); break; default: clientHandler?.WriteMessage("Invalid command Id"); break; } }