实时网络服务

发布于 2024-08-31 09:10:48 字数 502 浏览 2 评论 0原文

我有一个关于网络服务和服务器端编程的小问题(也许答案可能需要一本书)。

但首先,有一点序言。 最近我们看到了新类型的应用程序和应用程序。使用某种与数据库(或者更一般地说,与其他用户)进行实时交互的游戏。我说的是共享绘图画布,像这个这样的游戏,或简单的聊天,或 Android 应用程序“照片世界”,您可以实时查看谁在线,分享您的照片等。

现在我的问题是: 所有这些应用程序都是基于经典的 TCP 客户端/服务器架构吗?还是有办法以更简单的方式制作它们,例如 LAMP 这样的 Web 平台?

换句话说,我要问的是: PHP+MySQL(或者JSP,或者RoR,或者任何其他服务器语言)能否提供一种让在线用户实时交流、共享数据的方式?有没有一种方法可以做到这一点,而无需使用丑陋而笨重的临时表机制?

谢谢你!我希望我已经说清楚了。

I have a little (maybe the answer could require a book) question about web services and server side programming.

But first, a little preamble.
Recently we have seen new kind of applications & games using some kind of real-time interaction with a database, or more generally, with other users. I'm talking about shared drawing canvas, games like this , or simple chats, or the Android app "a World of Photo", where in real time you see who is online, to share your photos, etc.

Now my question:
Are all these apps based on classic TCP client/server architectures or is there a way to make them in a simpler way, like a web platform like LAMP?

What I'm asking, in other words is:
Can PHP+MySQL (or JSP, or RoR, or any other server language) provide a way to make online users communicate in real time and share data? Is there a way to do that without the ugly and heavy mechanism of temporary tables?

Thank you! I hope I've been clear.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

旧故 2024-09-07 09:10:48

有一种疯狂的黑魔法叫做 P2P(点对点)这使得这一切成为可能。

我不知道,但我认为它不会流行。

8-D

There is this crazy black magiccy thing called P2P (peer-to-peer) that makes all of this possible.

I don't know, but I don't think it will catch on.

8-D

温柔嚣张 2024-09-07 09:10:48

编辑:废话......我没有看到问题发布的日期。

我简直不敢相信。这是我连续第三个涉及 XHR 长轮询(又名彗星编程)的问题。 Daliz,你想要的东西是可能的、简单的,并且已经被各种网站使用 XHR 长轮询完成了。

概念:通常,网络浏览器向服务器发送请求,服务器发回响应并关闭与浏览器的连接。 Comet 编程不会在最后关闭连接,而是保持连接打开。因此,浏览器和服务器之间的连接仍然打开。因此,简单来说,当我们想要连接到 Alice 时,我们会找到连接到她的浏览器的线程并将消息发送给 Alice。

Facebook 口号使用了相同的概念。 请阅读本文

如果您的客户端不是网络浏览器而是某种网络服务,那么这就更容易了。与网络浏览器不同,网络服务有一个地址。因此,客户端服务使用回调 URL 调用主服务并注册特定事件。当该事件发生时,例如有人画东西,主服务将使用客户端服务的回调 url 来通知该操作。

在共享照片或其他二进制数据等数据时:也可以将来自一个用户的输入流发送到所有其他相关用户。因此可以共享一个简单的字符串或一张照片。但这也意味着照片接收端的用户不会收到类似“xxx已向您发送照片,点击此处下载”之类的消息。他们只会得到一个“您想打开还是保存此文件”选项。

EDIT: CRAP....I didn't see the date the question was posted.

I can't believe it. This is my third consecutive question that involves XHR Long Polling aka Comet programming. Daliz, what you want is possible, easy and been done by various websites using XHR Long Polling.

The concept: Normally, web browsers send a request to the server, server sends a response back and closes the connection to the browser. Instead of closing the connection at the end, Comet programming keeps the connection open. So, the connection between the browser and the server is still open. So, in simple terms, when we want to connect to Alice, we find the thread connecting to her browser and send the message to Alice.

Facebook chant uses the same concept. Please read This.

If your client is not a web browser but some web service, then it is more easy. Web services unlike web browsers have an address. So, client service calls the main service with a callback URL and registers to a particular event. When that event happens, like someone drawing something, main service will use the callback url of the client service to notify about that action.

On sharing data like Photos or another binary data: it is also possible as the input stream from one user is send to all other related users. So a simple String or a photo can be shared. But it also means the user on the receiving end of the photo will not have a message like "xxx has sent you a photo. Click here to download it". They will simply get a "Do you want to open or save this file" option.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文