3

只要图像在服务器中可用,我就需要将图像发送到客户端。客户端不是浏览器,而是 NAT(3G 网络)后面的某种设备(linux 机器),它将图像作为文件获取,将其写入磁盘,然后将其显示在屏幕上(这里没有浏览器)。

我是 nodejs 和 websocket 的新手。

我可以使用 nodejs 作为设备中的 websocket 客户端,使用 nodejs 作为服务器吗?你能提供一个使用nodejs执行websocket客户端的例子吗?

在这种情况下,nodejs能否检测到3G网络丢失然后恢复或重启websocket?

如果在 nodejs 服务器将图像推送到设备 nodejs(客户端)时发生连接丢失会发生什么?有没有简历解决方案?

Binary Js 如何处理 2 个 nodejs 之间的文件传输?

我可以使用像 ActiveMQ 这样的 MOM 使用一些 pub/sub 机制来做到这一点吗?

4

1 回答 1

3

Socket.io (which is probably what you'll want to use server-side) has a client module that works in node. It handles maintaining a connection to the server.

What you'll probably want to do is not push the image itself over the WebSocket connection. Instead, send a "new image available" notification message over the WebSocket, and when the client receives the message, make a regular HTTP GET request to the server to download the image.

Since you're making a regular HTTP request, you can use the Range header if you need to resume an interrupted download.

于 2013-08-21T18:26:38.290 回答