4

related

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

  1. try to get socket.io to communicate with a C# DLL, or do I
  2. 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?
  3. 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.

Community
  • 1
  • 1
mpen
  • 272,448
  • 266
  • 850
  • 1,236
  • See http://stackoverflow.com/questions/2064641/is-there-a-websocket-client-implemented-for-net – Polity Nov 04 '11 at 06:48
  • @Polity: This is for a website, not a Windows Forms/WPF application. I want to use JS client-side. I suppose Silverlight is an option too if necessary, but I'm not quite sure how that question relates. – mpen Nov 04 '11 at 06:51

1 Answers1

2

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?)

JAM
  • 6,045
  • 1
  • 32
  • 48
  • That looks pretty nice. I haven't touched C# in a little while now, but if it comes up again, I'll be sure to take a deeper look at SignalR! – mpen May 07 '13 at 15:33
  • @Mark Did I solve your question, or do you need further help? – JAM May 13 '13 at 14:28
  • Well, like I said, I haven't used C# for awhile. Couldn't tell you if this works for me or not ;) – mpen May 13 '13 at 15:32