Example #1
0
        /// <summary>
        /// Called when [server data recieved].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="Communication.Model.Event.DataReceivedEventArgs"/> instance containing the event data.</param>
        private void OnServerDataRecieved(object sender, Communication.Model.Event.DataReceivedEventArgs <string> e)
        {
            CommandMessage cmdMsg = CommandMessage.FromJSON(e.Data);
            IClientCommunicationChannel <string> receiver = (IClientCommunicationChannel <string>)sender;
            string msg = null;

            if (cmdMsg.CmdId == CommandEnum.CloseClientCommand)
            {
                receiver.Close();
            }
            else if (cmdMsg.CmdId == CommandEnum.CloseCommand)
            {
                m_imageServer.sendCommand(CommandEnum.CloseCommand, new string[] { }, cmdMsg.Args[0]);
                ServerCommunication.Instance.Send(new CommandMessage(CommandEnum.CloseCommand, cmdMsg.Args).ToJSON());
            }
            else
            {
                bool result;
                msg = m_controller.ExecuteCommand((int)cmdMsg.CmdId, cmdMsg.Args, out result);
            }

            if (msg != null)
            {
                receiver.Send(msg);
            }
        }
 /// <summary>
 /// Closes this instance.
 /// </summary>
 public void Close()
 {
     Send(new CommandMessage(CommandEnum.CloseClientCommand, new string[] { }));
     m_client.Close();
     m_client = null;
 }