comet

Persistent local domain socket in php

送分小仙女□ 提交于 2019-12-13 13:31:49
问题 The answers I've found to this question (such as here, here, and here) all involve pfsockopen(), which seems geared to non-local socket connections. However, the code I've written so far uses php to access a C++ server through a local connection. I want this connection to be persistent (so that I can use it for Comet, incidentally). Here's my non-persistent version: <?php session_start(); ... if (($sock = socket_create(AF_UNIX, SOCK_STREAM,0)) === false) { echo "socket_create() failed: reason

how to implement comet via gevent's event

别等时光非礼了梦想. 提交于 2019-12-13 08:39:24
问题 there's a demo on how to implement comet using gevent + flask. #coding:utf-8 ''' Created on Aug 6, 2011 @author: Alan Yang ''' import time from gevent import monkey monkey.patch_all() from gevent.event import Event from gevent.pywsgi import WSGIServer from flask import Flask,request,render_template,jsonify app = Flask('FlaskChat') app.event = Event() app.cache = [] app.cache_size = 12 @app.route('/') def index(): return render_template('index.html',messages=app.cache) @app.route('/put'

Cometd : Multiple tabs for online-users management creating false online-status

喜夏-厌秋 提交于 2019-12-13 06:45:01
问题 I am working on a Spring-MVC based web-app which uses Cometd for chat purposes. For real-time management of which user is online, we are sending notifications when the user is online. So when window is closed, then notifications don't appear and after 30 seconds it is determined that the user is offline or not reachable. Now the problem happens when user is over multiple browsers. Lets just keep it for 2 now. So, after 10 minutes we are setting user status to 'Away from Keyboard'(AFK). But if

Why doesn't this PHP code (comet) work?

≯℡__Kan透↙ 提交于 2019-12-13 06:22:26
问题 set_time_limit(0); header("Cache-Control: no-cache, must-revalidate"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); flush(); while($i < 10) { sleep(1); $i++; echo $i; flush(); } Why doesn't my code print out 1, then wait and print 2 then wait and print 3. Instead, it just waits 10 seconds and prints out 12345678910 all at once? Is there a way to print it in chunks as I want? 回答1: It's likely because of output buffering. Try adding this at the top of the file to close all the open buffers

How can i stop a server sent event script from running when the user closes the page? PHP

寵の児 提交于 2019-12-13 01:55:11
问题 Im trying to use SSE in PHP backend to send messages to a user. the functional part of the backend code looks like- <?php set_time_limit(0); header('Content-Type: text/event-stream'); header('Cache-Control: no-cache'); ignore_user_abort(0); @session_start(); ob_start(); echo "retry: 1000\n"; ob_flush(); flush(); require_once 'sql_connection_class.php'; require 'chatbox_class.php'; $chatbox=new chatboxclass($_GET['friendid']); function recursivesenddata(){ global $chatbox; $jsonobj=$chatbox-

Server-Push Technology (aka. “COMET”, “http server push”, “websockets”)

孤人 提交于 2019-12-12 18:29:04
问题 What does MS/Azure offer in the way of server push technology? My guess is that there is not, as yet, an RTM offering for this. The Microsoft-oriented status of this technology, I believe is as follows: WCF: offers TCP duplexing, but requires two TCP sockets (where one is opened on the client). Ergo this is not COMET (and won't work through firewalls) WebSockets: Available from Microsoft's Html 5 Labs, but still very much under development ASP.NET: There is a "MS code samples" offering of

JavaScript library for push/comet/reverse-ajax notifications?

爱⌒轻易说出口 提交于 2019-12-12 18:04:52
问题 I'm planning on building a website where you can play (turn-based) games with other people. I need to be able to communicate which moves have been made. I think push-notifications are best suited for this. I've read a little bit about node.js; is that the way to go? Or are there other libraries that will make it easy to do this sort of thing? 回答1: There are a number of solutions with a number of different technologies. Node.js and socket.io is just one popular solution. If you are a Ruby

Can long-polling be achieved in Restlet by just making the thread sleep?

瘦欲@ 提交于 2019-12-12 17:24:00
问题 When making a GET request for a particular resource (i.e. ServerResource ) if I put the thread to sleep (to simulate long-polling) what would happen? Does the framework support this? From a Java EE standpoint what are the side-effects? Does it scale well with Tomcat (or any other server?) Has any-one tried implementing long-polling using Restlet by just making the request thread sleep? It seems restlet has no support for comet-style web applications and hence the question of such a hack , so

AJAX Progress Bar - Polling, Comet?

心已入冬 提交于 2019-12-12 16:40:49
问题 I would like some advice on how to implement the following: I would like to make my users aware of the progress of a task that is running on my server via AJAX. My server runs a PHP script that downloads a file via shell command using the popen function. It periodically echos/prints what is happening. I would like to capture this output using AJAX and present it to the user. I was told in another question that I might need to make use of polling or comet? I would really appreciate any help or

How do I get the requests for a servlet implementing CometProcessor interface to pass through a filter

爷,独闯天下 提交于 2019-12-12 14:21:22
问题 I have a servlet implementing CometProcessor and I am trying to get the requests coming to this servlet to pass through a filter. Specifying the servlet in web.xml under does not make the requests to the servlet to pass through the filter. I also tried implementing CometFilter and specified the servlet implementing CometProcessor in web.xml under . I get the following error - Jan 29, 2013 12:10:04 PM org.apache.catalina.connector.CoyoteAdapter service - SEVERE: An exception or error occurred