public async void Say(string message)
{
string url = string.Format("{0}{1}.campfirenow.com/room/{2}/speak.xml", Scheme, _config.AccountName, _roomId);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.ContentType = "application/xml";
request.Headers[HttpRequestHeader.Authorization] = string.Format("Basic {0}", EncodedAuthToken);
request.Accept = "application/xml";
using (var sw = new XmlTextWriter(await request.GetRequestStreamAsync(), Encoding.UTF8))
{
sw.WriteStartDocument();
sw.WriteStartElement("message");
sw.WriteElementString("type", "TextMessage");
sw.WriteElementString("body", message);
sw.WriteEndElement();
sw.WriteEndDocument();
}
HttpWebResponse response = null;
try
{
response = (HttpWebResponse) await request.GetResponseAsync();
}
catch (WebException ex)
{
response = (HttpWebResponse)ex.Response;
SystemMessage(string.Format("Failed to say '{0}': {1}", message, ex.Message));
}
}