PHP Comet (server side)
Possible duplicate:
Using comet with PHP?
I am writing a social application with an end written in PHP (I am using the FuelPHP framework). I would like to notify the client that an event has occurred on the server in a similar way to what Facebook does for him.
At the moment I'm just using re-polling using AJAX, but I think I could achieve a nicer implementation by using an event on the server to fire before the client.
Using node.js I have achieved this kind of communication with web sockets and the socket.io module.
Is there a way to do this in PHP? Is PHP really inappropriate for this kind of communication? Can I create a node based child process in some way?
This is a lack of knowledge, can anyone point me to a solution that I can investigate?
This code can illustrate what I am trying to do ...
private function initEvents() {
$events = Event::instance('chat_event_listener');
$events->register('messageWasReceived', function($message){
$this->handleMessageReceived($message);
});
}
public function post_addNewMessage(){
//Client uses Posts message to this method using AJAX
$message = \Input::post('message');
Event::instance('chat_event_listener')->trigger('messageWasReceived', $message);
return $this->response(array(
'success' => true,
'data' => 'TO DO',
));
}
private function handleMessageReceived($message){
$this->firephp->log('Message received on server: ' . $message);
//notify client
}
source to share
No one has answered this question yet
See similar questions:
or similar: