Node中有没有一个好的库用于客户端和服务器之间的异步通信?
是否有一个库可以让我在 Node.js 服务器上运行一个函数,并且可以同时在连接到服务器的所有客户端上调用相关函数,而不是手动创建每个 websocket 并定义整个结构?同样,我可以从客户端浏览器安全地调用服务器功能吗?我觉得每次我必须构建一个通过网络套接字发送的命令时,我都是在传输层而不是应用程序层工作,并且我想要在更高层思考整个时间。
如果它还不存在,我不介意自己构建这样的东西,但我很难相信这个问题还没有在节点上得到解决。
Instead of creating every websocket and defining the entire structure by hand, is there a library that will let me run a function on the Node.js server, that can call a related function on all clients connected to the server simultaneously? Likewise, can I securely call a server function FROM the client browser? I feel like every time I have to construct a command to send over the web socket, I'm working on the transmission layer instead of the application layer, and I want to be thinking at the higher layer the entire time.
I wouldn't mind building something like this myself if it doesn't already exist, but I have a hard time believing this isn't solved on node already.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您真正需要的是 Node.js RPC 解决方案。以下是一些 node.js RPC 选项:
我没有亲自使用过它们,但它们看起来很有潜力。
What you are really looking for is an node.js RPC solution. Here are a couple of node.js RPC options:
I have not personally used them, but they look like they have good potential.
尝试查看 now.js。
Try to look at now.js.
尝试 msg-rpc,它只是提供你需要的 rpc 支持,对 websocket 也没有特殊要求您已有的服务器/客户端库。告诉如何发送消息并转发收到的消息,仅此而已。
Try msg-rpc, it just provides the rpc support you need, also no particular requirement for the websocket library of server/client you already have. Tell how to send out a message and forward the messages received, that's all.