如何获得实时更新? [英] How to get realtime updates?

查看:160
本文介绍了如何获得实时更新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Facebook上经常聊天,因为我喜欢代码越来越多,所以我试图创建一个聊天脚本!这里是:::
http://wooflux.co.cc/ ChatSystem.1.1 / ChatSystem.1.1 /



你试试看。但它只是一个测试版,所以有一些bug。最大的错误之一是需要一个良好的互联网速度才能实时更新。但是当我把网速推到最大值,然后和我的一个朋友在Facebook上聊天时,它实时工作!我想知道他们是怎么做到的?任何人都可以解释我们是如何实现的。目前我正在发送数字间隔的Ajax请求以获得实时更新。所以请帮我解释一下如何做Facebook实时聊天,而不用大量的互联网速度?

解决方案

p>要进行实时通信,您需要正确的连接。



您可以使用 WebSockets 为您提供真正的浏览器 - 服务器TCP连接。



WebSockets的替代品将是闪存桥(在Flash中使用websockets)或 COMET 技术。



我的个人建议是一个WebSocket抽象,如 socket.io



Socket.io基于 node.js 哪些Serverside Javascript。它在事件异步实时通信方面表现出色。



如果您的节点路由下降,您可能会同时选择 / code> ,使你的生活变得轻松。它有一个关于在12行中进行聊天服务器的屏幕截图。


I was chatting frequently in Facebook and as I love to code more and more so I tried to create a Chat Script! Here it is ::: http://wooflux.co.cc/ChatSystem.1.1/ChatSystem.1.1/

You try it out. But it is just a beta version so there are some bugs in it. And one of the biggest bug is that it requires a good internet speed to get real time updates. But when I push my net's speed to it's maximum and then chat with one of my friends in Facebook, it work in real time! I was wondering how did they do that? Can anyone explain me how they achieved this. Currently I'm sending Ajax requests in number intervals to get real time update. So please help me out by explaining or giving a link that how did Facebook achieved real time Chats without using much of the Internet speed?

解决方案

To do real time communication you need a proper connection.

You can use WebSockets to give you a real Browser - Server TCP connection.

The alternative to WebSockets would be a flash bridge (which uses websockets in flash) or COMET techniques.

My personal recommendation is a WebSocket abstraction like socket.io.

Socket.io builds on node.js which Serverside Javascript. It excels at evented asynchronous real time communication.

If your going down the node route you might aswell pick up now to make your life easy. It has a screencast about making a chat server in 12 lines.

这篇关于如何获得实时更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆