JakartaJEEWebDevelopment

Jakarta JEE8 Enterprise Web Development

View on GitHub

2. Creating Multi-player Games with WebSockets

Welcome to “Creating Multi-player Games with WebSockets.” In this course module, we’ll explore the fascinating world of WebSockets and learn how to build multi-player games using these real-time communication tools. We’ll begin by delving into practical examples provided by Tomcat 9, covering WebSocket applications like Echo, Chat, Multiplayer Snake, and Multiplayer Drawboard.

Getting Started

To get started, follow these steps:

  1. Launch Tomcat 9: Use the startup.bat script from the command line to start your Tomcat 9 server.

  2. Explore WebSocket Examples: Access the WebSocket examples by visiting http://localhost:8080/examples/websocket/index.xhtml in your web browser. Here, you’ll find a range of WebSocket applications to experiment with.

  3. Local Tomcat 9 Location: The local instance of Tomcat 9 is located at C:\apache-tomcat-9.0.68\webapps\examples. You can refer to this directory for your local WebSocket development.

  4. Source Code on GitHub: For in-depth understanding and exploration of the source code, check out the WebSocket examples on GitHub Tomcat 9 & GitHub Tomcat Master

WebSocket Examples

We’ll dive into the following Apache Tomcat WebSocket examples:

  1. Echo Example: Learn how to create a basic WebSocket application that echoes messages back to the sender.

  2. Chat Example: Explore a real-time chat application that allows multiple users to communicate instantly.

  3. Multiplayer Snake Example: Develop a multi-player snake game that showcases the power of WebSockets in gaming.

  4. Multiplayer Drawboard Example: Create a collaborative drawing board where multiple users can draw and interact in real time.

Application Integration

In an upcoming section of this course, we’ll take the knowledge gained from these examples and apply it to our charity-registration web application. We’ll specifically focus on building a real-time chat module, enhancing the user experience and interactivity of our web application.