Example #1
0
 /// <summary>
 /// Gets a client Instance and registers to the ServerCommandRecieved event.
 /// </summary>
 public SettingsModel()
 {
     Client = TcpClientChannel.Instance;
     Client.RecieveCommand();
     Client.ServerCommandRecieved += ServerCommandRecieved;
     Initializer();
 }
Example #2
0
 /// <summary>
 /// Prevents a default instance of the <see cref="ServerCommunication"/> class from being created.
 /// </summary>
 private ServerCommunication()
 {
     m_server     = new TcpClientChannel(IP, PORT);
     m_server_app = new TcpServerChannelByte(IP, APP_PORT);
     m_server.Start();
     m_server_app.Start();
 }
Example #3
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);
            }
        }
Example #4
0
 /// <summary>
 /// Gets a client Instance and recieved the IsConnected status.
 /// </summary>
 public MainModel()
 {
     Client    = TcpClientChannel.Instance;
     Connected = Client.IsConnected;
     Students  = new List <Student>();
     MakeStudentsList();
 }
Example #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NewClientEventArgs"/> class.
 /// </summary>
 /// <param name="newClient">The new client.</param>
 public NewClientEventArgs(IClientCommunicationChannel <T> newClient)
 {
     NewClient = newClient;
 }
Example #6
0
 /// <summary>
 /// Prevents a default instance of the <see cref="ServerCommunication"/> class from being created.
 /// </summary>
 private ServerCommunication()
 {
     m_server = new TcpServerChannel(IP, PORT);
     m_server.Start();
 }
 /// <summary>
 /// Closes this instance.
 /// </summary>
 public void Close()
 {
     Send(new CommandMessage(CommandEnum.CloseClientCommand, new string[] { }));
     m_client.Close();
     m_client = null;
 }
 /// <summary>
 /// Prevents a default instance of the <see cref="ClientCommunication"/> class from being created.
 /// </summary>
 private ClientCommunication()
 {
     m_client = new TcpClientChannel(IP, PORT);
     m_client.Start();
 }
 /// <summary>
 /// Gets a client Instance and recieved the IsConnected status.
 /// </summary>
 public MainWindowModel()
 {
     Client    = TcpClientChannel.Instance;
     Connected = Client.IsConnected;
 }
Example #10
0
 /// <summary>
 /// Gets a client Instance and registers to the ServerCommandRecieved event.
 /// </summary>
 public LogModel()
 {
     Client = TcpClientChannel.Instance;
     Client.ServerCommandRecieved += ServerCommandRecieved;
     Initializer();
 }
Example #11
0
 public NewClientEventArgs(IClientCommunicationChannel a_client)
 {
     Client = a_client;
 }