M
Mike Davies
Hi,
I'm developing an APP which pushed web content to various devices on a
LAN (these devices happen to be IP phones).
I need to broadcast a HTTP message to maybe 100 phones at a time but
this is really slow. I've tried different things but not sure what the
right way to go is. First way is to push the message to the phone but
this takes anywhere from 500ms to 1000ms to complete. Incidentally,
I'm not interested in the repsonse from the phone.
The other way I tried was to wait for the response asynchronously but
that didn't seem to work and was still quite slow at around 100ms.
I can't figure out how to push a message to all phones simultaenously
while ignoreing the repsonse. Can anyone point me in the right
direction.
Just to reiterate, I'm not interested in the response even though the
code below checks for a response. This is just because druing testing
I wanted to know if the phone received it or not. My problem is how do
I send a HTTP request to 100 phones at the same time and ignore the
response.
Cheers,
Mike
try
{
/
//Build URL to post execute command to
string pushUrl = "http://" + strDeviceIP +
"/CGI/Execute";
//The Following Creates the WebClient Object
System.Net.HttpWebRequest web =
(System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(pushUrl);
web.ProtocolVersion =
System.Net.HttpVersion.Version10;
web.KeepAlive = false;
web.Credentials = new
System.Net.NetworkCredential(strUsername, strPassword);
web.ContentType =
"application/x-www-form-urlencoded";
web.AllowAutoRedirect = true;
web.MaximumAutomaticRedirections = 5;
web.Method = "POST";
//web.Timeout = 1;
string pushxml =
"<CiscoIPPhoneExecute><ExecuteItem Priority=\"0\" URL=\"" + strURI +
"\"/></CiscoIPPhoneExecute>";
pushxml = "XML=" + HttpUtility.UrlEncode(pushxml);
//PostData is then declared as data type Byte and
populated with the post data
byte[] PostData =
System.Text.ASCIIEncoding.ASCII.GetBytes(pushxml);
//Send POST data (XML)
web.ContentLength = PostData.Length;
Stream dataStream = web.GetRequestStream();
dataStream.Write(PostData, 0, PostData.Length);
dataStream.Flush();
dataStream.Close();
//Send request
System.Net.HttpWebResponse wResponse =
(System.Net.HttpWebResponse)web.GetResponse();
//IAsyncResult r =
(IAsyncResult)web.BeginGetResponse(null, null);
//return IPPhoneReponse.Success;
//System.Net.HttpWebResponse wResponse =
(System.Net.HttpWebResponse)web.BeginGetResponse(null, null);
//Convert to XmlNode
XmlDocument doc = new XmlDocument();
doc.Load(wResponse.GetResponseStream());
//Handle Response
switch (doc.DocumentElement.Name)
{
case "CiscoIPPhoneResponse":
switch
(doc.SelectSingleNode("/CiscoIPPhoneResponse/ResponseItem").Attributes.GetNamedItem("Data").Value)
{
case "Success":
return IPPhoneReponse.Success;
case "":
return IPPhoneReponse.Success;
case "Failure":
return IPPhoneReponse.Failure;
default:
return IPPhoneReponse.Failure;
}
case "CiscoIPPhoneError":
if
(doc.SelectSingleNode("/CiscoIPPhoneError").Attributes.GetNamedItem("Number").Value
== "4")
{
return IPPhoneReponse.AccessDenied;
}
else
{
return IPPhoneReponse.Failure;
}
default:
return IPPhoneReponse.Failure;
}
}
catch (Exception e)
{
if (e.Message.IndexOf("timed-out") > 0)
{
return IPPhoneReponse.TimeOut;
}
if (e.Message.IndexOf("connect") > 0)
{
Debug.WriteLine(e.Message);
return IPPhoneReponse.TimeOut;
}
else
{
return IPPhoneReponse.Failure;
}
}
I'm developing an APP which pushed web content to various devices on a
LAN (these devices happen to be IP phones).
I need to broadcast a HTTP message to maybe 100 phones at a time but
this is really slow. I've tried different things but not sure what the
right way to go is. First way is to push the message to the phone but
this takes anywhere from 500ms to 1000ms to complete. Incidentally,
I'm not interested in the repsonse from the phone.
The other way I tried was to wait for the response asynchronously but
that didn't seem to work and was still quite slow at around 100ms.
I can't figure out how to push a message to all phones simultaenously
while ignoreing the repsonse. Can anyone point me in the right
direction.
Just to reiterate, I'm not interested in the response even though the
code below checks for a response. This is just because druing testing
I wanted to know if the phone received it or not. My problem is how do
I send a HTTP request to 100 phones at the same time and ignore the
response.
Cheers,
Mike
try
{
/
//Build URL to post execute command to
string pushUrl = "http://" + strDeviceIP +
"/CGI/Execute";
//The Following Creates the WebClient Object
System.Net.HttpWebRequest web =
(System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(pushUrl);
web.ProtocolVersion =
System.Net.HttpVersion.Version10;
web.KeepAlive = false;
web.Credentials = new
System.Net.NetworkCredential(strUsername, strPassword);
web.ContentType =
"application/x-www-form-urlencoded";
web.AllowAutoRedirect = true;
web.MaximumAutomaticRedirections = 5;
web.Method = "POST";
//web.Timeout = 1;
string pushxml =
"<CiscoIPPhoneExecute><ExecuteItem Priority=\"0\" URL=\"" + strURI +
"\"/></CiscoIPPhoneExecute>";
pushxml = "XML=" + HttpUtility.UrlEncode(pushxml);
//PostData is then declared as data type Byte and
populated with the post data
byte[] PostData =
System.Text.ASCIIEncoding.ASCII.GetBytes(pushxml);
//Send POST data (XML)
web.ContentLength = PostData.Length;
Stream dataStream = web.GetRequestStream();
dataStream.Write(PostData, 0, PostData.Length);
dataStream.Flush();
dataStream.Close();
//Send request
System.Net.HttpWebResponse wResponse =
(System.Net.HttpWebResponse)web.GetResponse();
//IAsyncResult r =
(IAsyncResult)web.BeginGetResponse(null, null);
//return IPPhoneReponse.Success;
//System.Net.HttpWebResponse wResponse =
(System.Net.HttpWebResponse)web.BeginGetResponse(null, null);
//Convert to XmlNode
XmlDocument doc = new XmlDocument();
doc.Load(wResponse.GetResponseStream());
//Handle Response
switch (doc.DocumentElement.Name)
{
case "CiscoIPPhoneResponse":
switch
(doc.SelectSingleNode("/CiscoIPPhoneResponse/ResponseItem").Attributes.GetNamedItem("Data").Value)
{
case "Success":
return IPPhoneReponse.Success;
case "":
return IPPhoneReponse.Success;
case "Failure":
return IPPhoneReponse.Failure;
default:
return IPPhoneReponse.Failure;
}
case "CiscoIPPhoneError":
if
(doc.SelectSingleNode("/CiscoIPPhoneError").Attributes.GetNamedItem("Number").Value
== "4")
{
return IPPhoneReponse.AccessDenied;
}
else
{
return IPPhoneReponse.Failure;
}
default:
return IPPhoneReponse.Failure;
}
}
catch (Exception e)
{
if (e.Message.IndexOf("timed-out") > 0)
{
return IPPhoneReponse.TimeOut;
}
if (e.Message.IndexOf("connect") > 0)
{
Debug.WriteLine(e.Message);
return IPPhoneReponse.TimeOut;
}
else
{
return IPPhoneReponse.Failure;
}
}