Skip to content

Lobby System Template for a multiplayer java game, with chat and other features, using JavaFX and socket TCP (will be extended to UDP).

License

Notifications You must be signed in to change notification settings

mikyll/JavaFX-MultiplayerLobbySystem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Downloads Contributors Forks Stargazers Issues MIT License
Java Eclipse

JavaFX-MultiplayerLobbySystem

JavaFX lobby system for multiplayer games with chat, ready toggle and kick/ban buttons, using TCP sockets by default.

Execution

  1. Download the latest release.
  2. Extract the content of the archive.
  3. Execute the Launcher.

Features

Feature Description Demo
Listen server The network topology that has been used is the Listen server: a client can become the server, and will host the game for other clients. Basically, when a client creates a new room it becomes a server, hosting the connection for other clients that will send a request and join the room. Listen server scheme
Nickname & IP address validation The nickname and address validations happen when the user types a key in the textfields as well as when he confirms (that's because the user could cut the text from the field, without typing any key, and the button would remain enabled). Validation example
Server: set min and max room size Before creating the room, the server can choose its size: how many users it can contain and how many are required to start the game. Room size example
Server: open/close the room The server can decide whether to close or open the room at will, preventing new users from joining or not. Open/close room example
Client: set ready/not ready The clients can set their state to ready or not ready. If everyone is ready, and the minimum user required is reached, the game can start. Ready/Not ready example
Server: kick a user The server can kick any user out of the room. This is useful when the minimum users required to start the game is reached, but someone won't set their state to ready. Kick user example
Server: ban a user The server can ban any user out of the room. Ban user example
Chat The chat allows users to communicate in real time, showing the timestamp of the messages and the user that sent it. The chat also shows when users connect or disconnect and when they get kicked out from the server. Chat example
Disconnection When the server leaves the room or closes the application, each connected user get disconnected. Disconnection example

Documentation

Read the full docs.

  • main schemes

Roadmap

to add:

  • update User list in server, when someone send the READY.
  • add arrow to identify which user a particular client is
  • refactor: use only one listView and put an HBox inside it(?)
  • add on close function to disconnect and stop the threads before closing the app
  • add "start game" button which enables when the room has the minimum users required
  • add open/close checkbox to allow users to join
  • check if the users get disconnected properly when closing the app by the Launcher
  • change the "this.client != null" check with NavState.MP_CLIENT (same for the server)
  • fix Join Existing Room validation
  • move Controller methods (in a proper order)
  • fix KickUser (removes the server too). The problem was that goBack(), instead of switchToMP, closed the connection, so client sent KICK and DISCONNECT before closing the socket
  • fix exception print stack (handle them in a more proper way)
  • catch Connection Reset
  • SocketException: Interrupted function call: accept failed, thrown when we back from the server room, when no one has been accepted yet
  • add a ban list (nickname/IP)
  • automatic textarea scrolling, to last message
  • catch java.net.SocketException: Socket closed, when server accepts a connection, the client leaves and the server goes back
  • add banned user throws null pointer exception on Linux, fix it and make a working build
  • show private and public IP address and be able to copy it
  • chat text message check length before sending (not more than 200 char?)
  • add copy in clipboard when clicking on a username (inside a room)
  • server can enable/disable the chat(?)
  • add timer after sending READY message
  • fix gui components to have proper dimension
  • add Datagram (UDP) variant
  • add HTTP/websocket variant(?)
  • create a logger (?) and log messages to file too
  • add an headless server to handle the room list (when a server creates a room it's inserted into the list, and the client can access that list to see those rooms)
  • use this template for CluedoApp

Built With

For the implementation I used Java 11 and JavaFX 11, Eclipse IDE (2020-03 (4.15.0)), and SceneBuilder to create the gui (FXML).

Java version: JavaSE-11 (jdk-11.0.11)
JavaFX version: JavaFX 11 (javafx-sdk-11.0.2)

References

LinkedIn GitHub followers