Exemplo n.º 1
0
 public void ShowWindowMessage(WindowMessage model)
 {
     CurrentShell?.Dispatcher?.Invoke(() =>
     {
         CurrentShell.ShowMessage(model.Message);
     });
 }
Exemplo n.º 2
0
        internal void AcceptClients()
        {
            CurrentShell.Output("Listening for new clients on port " + Port + "...");
            while (true)
            {
                try
                {
                    currentClient = listener.AcceptTcpClient();

                    OnClientConnected(currentClient);

                    Thread.Sleep(AcceptClientDelay);

                    currentClient = null;
                }
                catch (SocketException e)
                {
                    CurrentShell.Error("Couldn't listen for new clients, retrying! SocketException: " + e.Message);
                    Thread.Sleep(ListenerRetryDelay);
                    continue;
                }
            }
        }
Exemplo n.º 3
0
        private void Init()
        {
            using BinaryReader reader = new BinaryReader(Stream, Encoding.UTF8, true);

            string message;

            bool initSequence = false;

            try
            {
                message = reader.ReadString().Trim();
                if (message == "/beginInit")
                {
                    initSequence = true;                                          // Marks begin of init sequence
                }
            }
            catch (IOException e)
            {
                CurrentShell.Error("Init sequence failed, didn't receive any data! IOException: " + e.Message);

                Dispose();

                return;
            }

            // Read init messages
            while (initSequence)
            {
                try
                {
                    message = reader.ReadString().Trim();
                }
                catch (IOException e)
                {
                    CurrentShell.Error("Init sequence failed, didn't receive any data during sequence! IOException: " + e.Message);

                    Dispose();

                    return;
                }

                if (message.Contains("/ip"))                 // Sets ip
                {
                    try
                    {
                        string address = message.Substring(message.IndexOf(" ") + 1, message.Length - message.IndexOf(" ") - 1);
                        IP = IPAddress.Parse(address);

                        continue;
                    }
                    catch (FormatException ex)
                    {
                        CurrentShell.Error("Invalid IP Address received, retrying! FormatException: " + ex.Message);

                        continue;
                    }
                }
                else if (message.Contains("/name"))
                {
                    Name = message.Substring(message.IndexOf(" ") + 1, message.Length - message.IndexOf(" ") - 1);

                    continue;
                }
                else if (message == "/endInit")                 // Marks end of init sequence and starts client
                {
                    if (IP != null && Stream != null && Name != null)
                    {
                        CurrentShell.Output("Client ID: " + ID);
                        CurrentShell.Output("Name: " + Name);
                        CurrentShell.Output("IP Address: " + IP.ToString());

                        initSequence = false;
                        IsInit       = true;

                        return;
                    }
                    else
                    {
                        CurrentShell.Error("Insufficient init information received, retrying!");                         // If client didn't send sufficient information

                        continue;
                    }
                }
            }
        }
        protected async Task InternalNavigateToTabAsync(Type viewModelType, object parameter)
        {
            string navigationRoute = GetPageRouteForViewModel(viewModelType);

            await CurrentShell.GoToAsync(navigationRoute, true);
        }