mirror of
https://github.com/tiennm99/try-solver.git
synced 2026-08-03 13:14:03 +00:00
97ee581aed260b6da51b84ffd26f957060c0eb9a
chore: update vulnerable dependencies and add Maven CI Bump jackson-databind 2.15.2 -> 2.22.1, logback-classic 1.4.8 -> 1.5.38, slf4j-api 2.0.7 -> 2.0.17, and netty-all 4.1.94 -> 4.1.136 to clear all open Dependabot security advisories. Add a GitHub Actions workflow building on JDK 11, and a .gitignore for Maven/IDE artifacts. @
Netty WebSocket Game Server
A simple game server implementation using Netty 4 with WebSocket support.
Features
- WebSocket-based game server using Netty 4
- JSON message protocol for client-server communication
- Built-in HTTP server for serving the web client
- Simple web-based test client
Prerequisites
- Java 11 or higher
- Maven 3.6 or higher
Building the Project
mvn clean package
Running the Server
java -cp target/netty-game-server-1.0-SNAPSHOT.jar com.gameserver.GameServer
By default, the server runs on port 8080. You can specify a different port as a command-line argument:
java -cp target/netty-game-server-1.0-SNAPSHOT.jar com.gameserver.GameServer 9000
Testing the Server
- Start the server using the instructions above
- Open a web browser and navigate to
http://localhost:8080 - Use the web interface to send test messages to the server
Message Protocol
The server uses a simple JSON-based message protocol:
{
"type": "MESSAGE_TYPE",
"payload": "Message content"
}
Supported Message Types
PING: Basic ping message- Any other type will be echoed back with a
SERVER_RESPONSEtype
Project Structure
GameServer.java: Main server class that initializes NettyGameWebSocketHandler.java: Handles WebSocket frame processingGameMessage.java: Message model for client-server communicationHttpStaticFileHandler.java: Serves static web contentindex.html: Web-based test client
Languages
Java
81.3%
HTML
18.7%