Exemple #1
0
        static void Main(string[] args)
        {
            List <Coordinate> list = new List <Coordinate>();

            Coordinate c1 = new Coordinate {
                lng = 8.692384, lat = 55.575616
            };
            Coordinate c2 = new Coordinate {
                lng = 8.682384, lat = 55.475616
            };
            Coordinate c3 = new Coordinate {
                lng = 8.652384, lat = 55.775616
            };
            Coordinate c4 = new Coordinate {
                lng = 8.632384, lat = 55.975616
            };
            Coordinate c5 = new Coordinate {
                lng = 8.72384, lat = 55.15616
            };

            list.Add(c1);
            list.Add(c2);
            list.Add(c3);
            list.Add(c4);
            list.Add(c5);

            SelfHoster sh = new SelfHoster();

            sh.Run(list);
        }
Exemple #2
0
        private void Client_Load(object sender, EventArgs e)
        {
            Hide();

            //Get login info and try connecting
            using (Login login = new Login())
            {
                login.ShowDialog();

                //if no username or server specified, and not self host, close window
                //if parameters are met, start self hoster if applicable or connect to server with username
                if (string.IsNullOrEmpty(login.Username) && string.IsNullOrEmpty(login.ServerIP))
                {
                    Close();
                }
                else if (login.IsSelfHost)
                {
                    SelfHoster.RunWorkerAsync();
                    serverIP = Array.Find(Dns.GetHostEntry(string.Empty).AddressList,
                                          a => a.AddressFamily == AddressFamily.InterNetwork).ToString();
                    Window_Title.Text = $"Cynobroad Client - Local Server Running at {serverIP}";
                }
                else
                {
                    serverIP = login.ServerIP;
                }

                username = login.Username;
                User_UsernameLabel.Text   = username;
                User_ConnectedServer.Text = serverIP;

                try
                {
                    _client     = new TcpClient();
                    isConnected = true;
                    InitializeConnection();

                    //show main form and close login dialog
                    Show();
                    SendMsgBox.Focus();
                }
                catch
                {
                    isConnected = false;
                }
            }

            //if connection failed set status to red, else green
            if (!isConnected)
            {
                User_ConnectionStatus.BackColor = Color.FromArgb(224, 102, 102);
            }
            else
            {
                User_ConnectionStatus.BackColor = Color.FromArgb(147, 196, 125);
            }
        }
Exemple #3
0
        private void Button_SignOut_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            //send closing request and reset variables
            CreateAndSendPacket("close");
            Thread.Sleep(10);
            isConnected = false;
            _client.Close();
            SelfHoster.Dispose();

            //rerun launch method to sign in again
            Client_Load(sender, e);
        }