I am in a position of researching new technologies , so I heard something about Long polling,node.js.
I need to create a web application that which use long polling
.
On each and every page of this project i need to use polling , actually it checks if there is a new Email through POP.
So I think that I need to do the following
- Call a ajax request to the server
- Server receives the request and checks if there is a new Email
- If there is a new Mail server responds with its details
- If there is no new Email server started sleeping sometime and checking again until one new Email arrives.
so something like this
$(document).ready(function(){
is_there_new_mail();
function is_there_new_mail()
{
$.get(url,function(data){
if(data ==true)
{
//do some actions and call again
is_there_new_mail();
}
});
}
});
and in server something like this
function check_mail()
{
//processing and checking is there a new mail on inbox
return $is_mail = $this->_new_mail()?true:false;
}
function receiver()
{
if($check_mail())
{
//send to client..
}
else
{
//sleep sometime and call mail function
}
}
I heard that doing something like this will open many connection on server, and if we use node.js we can manage it with in one connection.
I am using Codeigniter, and really new to node.js.
How can I implement node.js with codeigniter, or could you please suggest me something more about this scenario.