/// <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"); } }
/// <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); }
/// <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"); } }
/// <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 { } }
/// <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); }
/// <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()); } }