コード例 #1
0
ファイル: AuthActivity.cs プロジェクト: arqtiq/RemotePlayerPi
        private void connexionBtnClick(object sender, EventArgs e)
        {
            Start(); return;

            string ip   = FindViewById <EditText>(Resource.Id.serverIPinput).Text;
            string port = FindViewById <EditText>(Resource.Id.serverPortInput).Text;

            Prefs.SaveIP(ip);

            if (string.IsNullOrWhiteSpace(ip) || string.IsNullOrWhiteSpace(port))
            {
                Toast.MakeText(ApplicationContext, "Input IP Adress or Port is empty", ToastLength.Long).Show();
                return;
            }

            ConnexionResult res = Network.Connect(ip, port);

            if (!res.Connected)
            {
                Toast.MakeText(ApplicationContext, "Unable to connect : " + res.Message, ToastLength.Long).Show();
                return;
            }

            Network.SendToServer(Command.Factory.Network.GetConnect());
            connecting = true;
        }
コード例 #2
0
ファイル: Network.cs プロジェクト: arqtiq/RemotePlayerPi
        static public ConnexionResult Connect(string IP, string port)
        {
            ConnexionResult result = new ConnexionResult();

            client = new UdpClient();
            ip     = new IPEndPoint(IPAddress.Parse(IP), int.Parse(port));

            try
            {
                client.Connect(ip);
                connected = true;
            }
            catch (Exception e)
            {
                result.Message = e.Message;
                connected      = false;
            }

            result.Connected = connected;
            return(result);
        }