简体   繁体   中英

How do you make a C# server that can store its connection to clients AND update them when needed

I'm trying to make a simple multiplayer turn based game. I have little experience with c# servers so I am trying to learn. It would need to be able to play something like chess over the internet.

My Goal : to have a server that can accept messages from clients (like join game, do a move, etc) and be able to store the Client's connection when they join and then update them on information in the game at any time, like when a opponent moves or something. (I would want to be able to expand it to more than two players)

My Problem : everything I can find about c# servers are sockets. The problem with sockets as far as I can tell is that they are one-way connections, meaning a client can only get data once after they send data. I would want to be able to update them multiple times after that, showing in close to realtime what happened in the game world after their turn is over.

How would I achieve this? Would I need clients to have listeners too? How do I store a connection when a new socket is created every time that a new request is made?

Thank you for any help/knowledge you can give!

I am not sure what sockets do you mean but WebSocket is a technology which, in a few words, enriches HTTP with full duplex communication between client and server. If we are talking about C# look at SignalR which can use WebSocket.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM