Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Java 

Making a server for a game in Java

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.
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
(Apr 7, 2019 09:45 AM)SIM-3991524 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 cheat

Lmk if you want more detail
I'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?
https://netty.io
also you can check https://github.com/topics/game-server?l=java
[Image: bitcoin.png] Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
(Apr 7, 2019 10:01 AM)Tenno Wrote:  I'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?

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
(Apr 7, 2019 10:36 AM)HFDone Wrote:  https://netty.io
also you can check https://github.com/topics/game-server?l=java
Thank you. I'll be looking at the differen repo's and see how they've done it.
(Apr 7, 2019 10:37 AM)SIM-3991524 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.

Basic idea is make the server do all the logic. Make the clients just a UI and webrequest
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?
(Apr 7, 2019 11:22 AM)Tenno Wrote:  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?

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
(Apr 7, 2019 11:36 AM)SIM-3991524 Wrote:  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

Really appreciate the help. I'll start making a prototype.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Java] by President HolyFeb 8, 2014 11:48 AM 3 189 Feb 8, 2014 11:48 AM
Last Post: Knautschtabak
[Java] by yasjeFeb 6, 2014 04:10 AM 23 457 Feb 6, 2014 04:10 AM
Last Post: yasje
[Java] by skullmaneyDec 31, 2013 01:15 PM 9 304 Dec 31, 2013 01:15 PM
Last Post: Spectro_Shifter