static EventListener() { lyncClient = new LyncHttpClient() { Timeout = TimeSpan.FromMinutes(15.0d) }; InitializeDictionary(); nextLink = Program.ApplicationInstance._links.events.href; samayeSamaye.Tick += samayeSamaye_Tick; samayeSamaye.Start(); GetEvents(); }
public static async Task Call(string phoneNumber, string to) { MainForm.callLabel.Text = "Attempting call..."; if (Program.ApplicationInstance._embedded.communication._links.startPhoneAudio == null) return; if (Program.ApplicationInstance._embedded.communication._links.startPhoneAudio.href.IsEmpty()) { var response = await (new LyncHttpClient()).PutAsync( Program.ApplicationInstance._embedded.communication._links.self.href, new StringContent("")); if (response.IsSuccessStatusCode) { Program.ApplicationInstance._embedded.communication._links.startPhoneAudio.href = (string)(JObject.Parse(await response.Content.ReadAsStringAsync())).SelectToken("_links.startPhoneAudio.href"); } else { MainForm.callLabel.Text = "Failed"; return; } } var lyncClient = new LyncHttpClient(); var lyncResponse = await lyncClient.PostAsync(Program.ApplicationInstance._embedded.communication._links.startPhoneAudio.href, new StringContent( await Task.Run<string>(delegate { return JsonConvert.SerializeObject(new StartPhoneAudioPayload() { //Fill these values Importance = "Normal", OperationId = Guid.NewGuid().ToString(), PhoneNumber = phoneNumber, Subject = "We want to see that what we think should work actually works.", ThreadId = Guid.NewGuid().ToString(), To = String.Concat("sip:", to) }); }), Encoding.UTF8, "application/json")); lyncResponse.ToString(); }
public static async Task<HttpResponseMessage> FollowUser(Uri userUrl) { il.AddCurrentLoginStatus("Attempting to GET User resource..."); try { if (0 != Settings.Default.OAuthToken.Trim().Length) { il.AddCurrentLoginStatus("OAuth token is available; attempting request with Authorization HTTP header attached..."); Settings.Default.DomainAddress = userUrl.AbsoluteUri.Replace(userUrl.PathAndQuery, String.Empty); LyncHttpClient = new LyncHttpClient(); return await LyncHttpClient.GetAsync(userUrl); } else { il.AddCurrentLoginStatus("OAuth token was not found; attempting request without Authorization header..."); return await httpClient.GetAsync(userUrl); } } catch (Exception ex) { il.AddCurrentLoginStatus(String.Format("Failed this time. Status Code: {0}\nMessage: {1}\n", response.StatusCode.ToString(), ex.Message.ToString())); } return new HttpResponseMessage(HttpStatusCode.BadRequest); }