| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
JSocket provides a simple yet powerful WebSocket implementation in Java with no external dependencies. Perfect for learning WebSocket internals, building custom real-time features, or integrating into existing Java applications.
Chess game demo built with JSocket
# Clone the repository
git clone https://github.com/AceAtDev/JSocket--java-simple-websocket
cd JSocket
# Run the Chess server (using your IDE or command line)
java javaWebsocketChess.chess.ChessServerMain
# Open in browser: javaWebsocketChess/chess/clientApp/index.html
# (Open in two tabs to play against yourself)1️⃣ Copy the core files from javaWebsocketChess/websocketCore/ into your project
2️⃣ Create your handler:
public class MyWebSocketHandler implements WebSocketListener {
@Override
public void onOpen(ClientHandler connection) {
connection.sendMessage("Welcome!");
}
@Override
public void onMessage(ClientHandler connection, String message) {
System.out.println("Received: " + message);
connection.sendMessage("You said: " + message);
}
@Override
public void onClose(ClientHandler connection, int code, String reason, boolean remote) {
System.out.println("Connection closed: " + reason);
}
@Override
public void onError(ClientHandler connection, Exception ex) {
ex.printStackTrace();
}
}3️⃣ Start the server:
public static void main(String[] args) {
WebSocketServer server = new WebSocketServer(8888, new MyWebSocketHandler());
try {
server.start();
System.out.println("WebSocket server running on port 8888");
} catch (IOException e) {
e.printStackTrace();
}
}JSocket's architecture is simple but powerful:
For more detailed information:
Contributions are welcome! Whether it's bug reports, feature requests, or code contributions:
JSocket is MIT licensed.
Special thanks to the amazing python-websockets/websockets project for their wonderful documentation, which was invaluable in creating this repository.
| Back | FazBrowse Home | New Git URL |