是否可以将 socket.io 客户端与自定义 C# Web 服务器一起使用?
我正在构建一个网站,您可以在其中玩游戏。当玩家做出移动时,我想将该移动发送到服务器,然后使用 C# 计算响应并将其返回给客户端。我可以用 JavaScript 完成所有客户端的工作,我只是想弄清楚应该如何进行通信。
我正在考虑使用 socket.io,但我相信这需要我用 JS 编写服务器和客户端。所以,我不确定该采取什么方法。我是否
- 尝试让 socket.io 与 C# DLL 进行通信,或者
- 用 C# 编写整个 Web 服务器(应该相对简单,不是吗?)。如果是这样,我还可以使用 socket.io 客户端吗?它只是向服务器发送基本请求,我应该能够捕获这些请求,不是吗?
- 或者我应该完全放弃socket.io,而只使用jquery+ajax向我的服务器发送http请求......但是我该如何响应呢?另外,HTTP 不如套接字高效/轻量,不是吗?
我希望保持通信尽可能轻松,以便获得更快的响应时间和更轻的服务器负载。
I'm building a website where you can play games. When the player makes a move, I want to send that move to the server, then use C# to compute a response and return that back to the client. I'm fine with doing all the client-side stuff in JavaScript, I'm just trying to figure out how I should do the communication.
I was thinking about using socket.io, but I believe that requires me to write both the server and client in JS. So, I'm not sure what approach to take. Do I
- try to get socket.io to communicate with a C# DLL, or do I
- write the whole web-server in C# (should be relatively simple, no?). If so, can I still use socket.io client-side? It's just sending basic requests to the server, which I should be able to catch, no?
- Or should I drop socket.io altogether, and just use jquery+ajax to send http requests to my server....but then how do I respond? Also, HTTP isn't as efficient/lightweight as sockets, is it?
I want to keep the communication as light as possible so that I can get fast response times and lighter server load.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看 SignalR: https://github.com/SignalR/SignalR
它是一种 socket.io到 ASP.NET 的端口(我假设您将用于您的网络服务器?)
Check out SignalR: https://github.com/SignalR/SignalR
It is sort of a socket.io port to ASP.NET (Which I'm assuming you will use for your webserver?)