示例#1
0
        /// <summary>
        /// isset($_GET['token']) && isset($_GET['username']) && isset($_GET['lat']) && isset($_GET['lon'])) {
        /// </summary>
        public async Task Connect(main refe)
        {
            HttpClient client = new HttpClient();

            string server = UserSingleton.server;

            server += "api.php?action=" + Action.ntm_connect.ToString();
            server += "&identifier=" + Identifier + "&username="******"&lat=" + Latitude + "&lon=" + Longitude + "&town=" + Town;

            try
            {
                string res = await client.GetStringAsync(server);

                ResponseApi result = ResponseApi.GetResponseApiFrom(res);

                if (result.isSuccess())
                {
                    Token     = result.info;
                    Connected = true;
                }
                else
                {
                    refe.DEBUG(server);

                    MessageDialog ms = new MessageDialog(server + "\n\n" + res);
                    await ms.ShowAsync();
                }
            }
            catch
            {
                main.MessageBox("Serveur Ne repond Pas");
            }
        }
示例#2
0
        /// <summary>
        ///  if (isset($_GET['lat']) && isset($_GET['lon']) && isset($_GET['token'])) {
        /// </summary>
        public async Task <List <Nearest> > Search(string who)
        {
            HttpClient client = new HttpClient();

            string server = UserSingleton.server;

            server += "api.php?action=" + Action.ntm_search.ToString();
            server += "&who=" + who;

            List <Nearest> ret = new List <Nearest>();

            try
            {
                string res = await client.GetStringAsync(server);

                ResponseApi result = ResponseApi.GetResponseApiFrom(res);

                if (result.isSuccess())
                {
                    ret = result.results;
                }
                else
                {
                    main.MessageBox(result.ToString());
                }
            }
            catch
            {
                main.MessageBox("Serveur ne Repond pas");
            }
            return(ret);
        }
示例#3
0
        /// <summary>
        ///  if (isset($_GET['lat']) && isset($_GET['lon']) && isset($_GET['token'])) {
        /// </summary>
        public async Task NearToMe(main refe)
        {
            HttpClient client = new HttpClient();

            string server = UserSingleton.server;

            server += "api.php?action=" + Action.ntm_neartome.ToString();
            server += "&token=" + Token + "&lat=" + Latitude + "&lon=" + Longitude;

            try
            {
                string res = await client.GetStringAsync(server);



                ResponseApi result = ResponseApi.GetResponseApiFrom(res);

                if (result.isSuccess())
                {
                    refe.usercurrent.Nearests = result.results;
                }
                else
                {
                    MessageDialog di = new MessageDialog(server + "\n\n" + res);
                    await di.ShowAsync();
                }
            }
            catch
            {
                main.MessageBox("Serveur ne Repond pas");
            }
        }
示例#4
0
        /// <summary>
        /// if (isset($_GET['user']) && isset($_GET['friend']) && isset($_GET['message'])) {
        /// </summary>
        /// <param name="token"></param>
        public async Task SendChatMessageAsync(string token, string message)
        {
            HttpClient client = new HttpClient();

            string server = UserSingleton.server;

            server += "api.php?action=" + Action.ntm_chat.ToString();
            server += "&user="******"&friend=" + token + "&message=" + message;

            try
            {
                string res = await client.GetStringAsync(server);

                ResponseApi result = ResponseApi.GetResponseApiFrom(res);

                if (!result.isSuccess())
                {
                    MessageDialog c1 = new MessageDialog(res);
                    await c1.ShowAsync();
                }
            }
            catch
            {
            }
        }
示例#5
0
        /// <summary>
        ///  if (isset($_GET['user']) && isset($_GET['friend']) && isset($_GET['message'])) {
        /// </summary>
        /// <param name="token"></param>
        public async Task <List <ChatMessage> > GetChatHistoryAsync(string token)
        {
            HttpClient client = new HttpClient();

            string server = UserSingleton.server;

            server += "api.php?action=" + Action.ntm_get_chat.ToString();
            server += "&user="******"&friend=" + token;

            List <ChatMessage> mss = new List <ChatMessage>();

            try
            {
                string res = await client.GetStringAsync(server);

                ResponseApi result = ResponseApi.GetResponseApiFrom(res);

                if (result.isSuccess())
                {
                    mss = result.chat;
                }
                else
                {
                    MessageDialog msg = new MessageDialog("Erreur de Serveur");
                }
            }
            catch
            {
                main.MessageBox("Serveur Ne repond Pas");
            }

            return(mss);
        }
示例#6
0
        /// <summary>
        ///     if (isset($_GET['token']) && isset($_GET['lat']) && isset($_GET['lon'])) {
        /// </summary>
        public async void Update()
        {
            HttpClient client = new HttpClient();

            string server = UserSingleton.server;

            server += "api.php?action=" + Action.ntm_update.ToString();
            server += "&token=" + Token + "&lat=" + Latitude + "&lon=" + Longitude;

            string res = await client.GetStringAsync(server);

            ResponseApi result = ResponseApi.GetResponseApiFrom(res);

            if (result.isSuccess())
            {
                main.MessageBox("Position Updated  to (" + Latitude + ", " + Longitude + ")");
            }
            else
            {
                main.MessageBox(result.ToString());
            }
        }