APE, It's the best idea for 2 ways connections between client & server. I think I can create ajax push engine based on Asp.net like the following code.
Server-side ( WCF or .Net Web Service )
public string SendRequest()
{
string data = Request["data"];
if(String.IsNullOrEmpty(data))
{
// still connect to client until server has new data for send to client.
while(!HasNewData())
{
Thread.Sleep(100);
}
// send new data to client.
JSONResponse.Send(GetNewData());
}
else
{
// Save data via Extension Method for easy to understand.
data.Save();
// Send response using default json template.
return JSONResponse.Complete;
}
}
But I have some problem about performance when server connect more than 100 client at the same time. Which is the best performance in server term?
- Client request server every few second.
- Client request server after server response last request.
Source : Ajax Push Engine - Real time data streaming
Thanks,