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