我可以浏览nodejs ws模块,以便浏览器成为Web Socket连接的服务器端

时间:2015-03-12 03:07:56

标签: node.js websocket browserify

我们都知道在浏览器中实现的Web套接字API只是客户端...但是如果我Browserify nodejs ws module并在浏览器端运行它可以充当Web套接字中的服务器连接?

1 个答案:

答案 0 :(得分:2)

Browserify ws module relies on C++ code built with node-gyp. No, you cannot use browserify to convert it to client-side Javascript. (Unless ws has some conditional compilation for builds under browserify.)

Anyway, let's think about it in a realistic way. Client-side Javascript interacts with the world via a limited API, which doesn't contain anything resembling Websocket server or TCP support. No, you cannot create a Websocker server on a client.

相关问题