Has anyone implemented the following php script in dancer: http://yuilibrary.com/gallery/show/eventsource What I wrote so far is: any ['get', 'post'] => '/chat/:session' => sub { if ( param('view') ){ template 'view', { id => param('session') }, { layout => undef }; }else{ content_type "text/event-stream"; # check every so often to see if there's new data while( 1 ) { # sleep for a second - simulate waiting for data sleep(1); # check for poll-only header if ( my $header = header("X-YUIEventSource-PollOnly") ){ # if it's a poll-only request, break the loop, which ends the request - the client will reconnect last; } return 'data: ' . request->uri_base . request->path . '?view=1'; # Of course it will also end here, the loop does not continue } return 'data: ' . request->uri_base . request->path . '?view=1'; } }; I am still getting some errors in the : src.on("error", function(event){ console.log("Error!"); });
participants (1)
-
Daniel M.