comet

PHP Comet. How to do it better?

拜拜、爱过 提交于 2019-12-06 06:09:48
问题 I have a simple comet chat. JavaScript send ajax request with long polling. When server find new messages in the database, it answers and gives JSON. Next, JavaScript send the request again. Javascript: function cometConnect(){ $.ajax({ cache:false, type:"get", data:'ts='+ts, url: urlBack, async: true, success: function (arr1) { //work with JSON //..... }, complete:function(){ cometConnect(true); nerr=false; }, dataType: "text" }); } PHP $flag=true; $lastmodif = isset($_GET['ts']) ? $_GET['ts

Implementing Comet on the database-side

可紊 提交于 2019-12-06 05:52:58
This is more out of curiosity and "for future reference" than anything, but how is Comet implemented on the database-side? I know most implementations use long-lived HTTP requests to "wait" until data is available, but how is this done on the server-side? How does the web server know when new data is available? Does it constantly poll the database? What DB are you using? If it supports triggers , which many RDBMSs do in some shape or form, then you could have the trigger fire an event that actually tells the HTTP request to send out the appropriate response. Triggers remove the need to poll...

How can I call a javascript function on client browser from NodeJS server side?

元气小坏坏 提交于 2019-12-06 05:01:24
问题 I'm programming on the NodeJS server side, I wish to call a javascript function on the client browser side. Hopefully I can call functions every now and then on the client browser side from the server side as if I an just calling the function on the server side. Is there some form or comet or RPC which can do this? 回答1: I checked out Socket.IO but ended up using Faye instead. Faye is probably a little more functionality than you want, but it's so easy to setup and use. I found it more

What is a safe amount of time that I can wait before responding to a browser, without getting a Timeout?

余生长醉 提交于 2019-12-06 03:11:16
问题 I'm making a chat application that works with long-polling to emulate a "push" from server to client. Basically, the browser asks for updates, and I reply if there's something new. Otherwise, I keep the connection open without responding until there is something to send back. Now, if 30 seconds have passed and I haven't sent anything, then I do send a response, saying basically "NoNews", and the client will poll again. What I want to do is obviously keep this connection without replying for

Can XMPP be used like Comet's http long wait?

半腔热情 提交于 2019-12-06 00:18:34
问题 Can XMPP be applied in a similar way to the reverse Ajax pattern? Can it be used to implement http long wait like Comet? Is there an example of using such a technique with XMPP? 回答1: Yes. Take a look at XMPP over BOSH. It's a long-lived non-polling technique. From the BOSH specification: This specification defines a transport protocol that emulates the semantics of a long-lived, bidirectional TCP connection between two entities (such as a client and a server) by efficiently using multiple

jquery comet long polling and streaming tutorials? [duplicate]

蹲街弑〆低调 提交于 2019-12-05 19:52:09
Possible Duplicate: Comet and jQuery im so tired of not finding good tutorials on long polling/streaming comet techniques with jquery. what is wrong with the comet community. a lot of people wanna use this but there are no good tutorials about it. why so slow? It's not a question about the comet community, it's just that this is only half of the problem. You eventually need a comet client (such as jquery, dojo, or custom clients according to the server), but first you need a comet server to connect to (such as Jetty, WebSync , etc). Once you pick the server, you can then pick the client. If it

PHP Jquery: chat system, what is the Ideal framework for this?

纵饮孤独 提交于 2019-12-05 07:47:20
I want to implement a chat system for my site. The functionality will be very similar to facebook chat. The chats will be one to one based. I know how to build the chat system using PHP, MySql and using JQuery. But my concern is that it won’t scale to large number of users in the long term. Using JQuery I would be making requests every second to keep the chat window updated or if the user is sending a request to chat with another user. This will cause extra load on the server as the user base will increase overtime. I’ve been told using PHP for this is not a ideal solution, that I should look

Comet framework for Django

笑着哭i 提交于 2019-12-05 02:46:28
问题 What is the easiest way to implement HTTP push (comet) on Django? Are there any existing frameworks? Simple examples would be great. 回答1: Try Oribited -- see example here and also this (No longer available) 回答2: Beacon is also an option. It's a cloud-hosted push service, meaning you don't have to install anything. Supports both WebSockets and traditional long-poll. Has a Python client too. 回答3: try with this to http://code.google.com/p/django-orbited/ 来源: https://stackoverflow.com/questions

JSONP Long Polling always loading

ぃ、小莉子 提交于 2019-12-05 02:24:21
问题 I'm doing long-polling with JSONP and firefox continually pops up the "Loading" spinner making the page seem like it hasn't finished loading. Is there a way to suppress this? I've been told that the Orbited team has hacks for suppressing this, but looking through the Orbited.js code I cannot figure out what they are. Any help would be greatly appreciated. 回答1: This is a simple fix.. All you have to do is start your polling request with a setTimeout.. Here is some code I use.. It uses jQuery,

how to implement redis's pubsub timeout feature?

删除回忆录丶 提交于 2019-12-05 00:17:45
I want to use Redis's pubsub feature to implement comet, but pubsub doesn't have timeout, so if I ps.listen() , it will block, even if client closes browser. greenlet has timeout feature when spawn process. but I don't know how to combine them together. flask's pseudo @app.route('/') def comet(): rc = redis.Redis() ps = rc.pubsub() ps.subscribe('foo') for item in ps.listen(): if item['type'] == 'message': return item['data'] # ps.listen() will block, so how to make it timeout after 30 s? Peter Moore Because you're not threading (and I'm assuming this is intentional and in some cases wise) you