![]() |
|
[Java] Making a server for a game in Java - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Java] Making a server for a game in Java (/showthread.php?tid=5957912) |
Making a server for a game in Java - Tenno - Apr 7, 2019 Hello, I'm trying to create my first multiplayer game. It's just a very simple variant of Uno, but I want to add multiplayer functionality to the game. However, I'm having a hard time figuring out how communication between clients should be handled, and who should be handling the game logic. I'm just looking for some advice, as I've got no experience with network programming. Who should keep track of cards that are on the table, the client or server? Should the server handle game logic and the clients request an action to be made, or should the clients handle it? Any advice is appreciated. RE: Making a server for a game in Java - SIM-3991524 - Apr 7, 2019 Nice man, my recommendation for a game where multiple player are going to connect is to implement a server that will host the game. Then your game clients can connect. Will hide player IPs and make it harder to cheat Lmk if you want more detail RE: Making a server for a game in Java - Tenno - Apr 7, 2019 (Apr 7, 2019 09:45 AM)f411en Wrote: Nice man, my recommendation for a game where multiple player are going to connect is to implement a server that will host the game. Then your game clients can connect. Will hide player IPs and make it harder to cheatI'd love more details. The thing is, I haven't figured out who should be in charge of what. What should the client do, and what should the server do to keep the game running? RE: Making a server for a game in Java - HFDone - Apr 7, 2019 https://netty.io also you can check https://github.com/topics/game-server?l=java RE: Making a server for a game in Java - SIM-3991524 - Apr 7, 2019 (Apr 7, 2019 10:01 AM)Tenno Wrote: I'd love more details. Create a server that is always listening. once >2 clients agree to start the game. Game starts, no new clients can join. Server keeps track of who has what cards, which players turn it is. Server tells all client which cards they are dealt, keeping other players cards private ofc. Tell all clients who's turn it is. Only let that player submit a card they put down. Server then says who is next... process continues. Server also has to notify all clients of which card is on the top of the pile. Basic idea is make the server do all the logic. Make the clients just a UI and webrequest RE: Making a server for a game in Java - Tenno - Apr 7, 2019 (Apr 7, 2019 10:36 AM)HFDone Wrote: https://netty.ioThank you. I'll be looking at the differen repo's and see how they've done it. (Apr 7, 2019 10:37 AM)f411en Wrote: Create a server that is always listening. once >2 clients agree to start the game. Game starts, no new clients can join. Server keeps track of who has what cards, which players turn it is. Server tells all client which cards they are dealt, keeping other players cards private ofc. Tell all clients who's turn it is. Only let that player submit a card they put down. Server then says who is next... process continues. Server also has to notify all clients of which card is on the top of the pile.How would the server notify players, and how would players receive the notifcations? Also, the server would need to use multiple threads to handle all connections and requests, right? RE: Making a server for a game in Java - SIM-3991524 - Apr 7, 2019 (Apr 7, 2019 11:22 AM)Tenno Wrote: How would the server notify players, and how would players receive the notifcations? Google "Creating a Simple Java TCP/IP Server and Client Socket" And yes, I personally would have the server create a new thread for every client RE: Making a server for a game in Java - Tenno - Apr 7, 2019 (Apr 7, 2019 11:36 AM)f411en Wrote: Google "Creating a Simple Java TCP/IP Server and Client Socket" Really appreciate the help. I'll start making a prototype. |