DEV Community

Cover image for Building a Multiplayer TicTacToe Game
Osinachi Chukwujama
Osinachi Chukwujama

Posted on • Edited on

Building a Multiplayer TicTacToe Game

Building real-time multiplayer games on the web require open channel communication using TCP or UDP. Websockets can be used to achieve real-time communication. A WebSocket is a TCP communication protocol that allows for two-way communication between a server and a client. When comparing WebSockets to HTTP, you'll learn that servers can communicate with clients without a request (trigger) from the client.

How the game is structured

The game follows the simple logic of

  1. Generate game code
  2. Share with a different player
  3. Play in multiple rounds You can see the live version here.

https://tic-tac-toe-trm58.ondigitalocean.app/

Live version

Deploying To Digital Ocean

Digital Ocean simplifies the deployment of applications through the app platform. They implemented a mechanism such that the type of app is detected an analysed. The deployment requirements are obtained and fixed in the deployment process.

So when I was deploying this app, Digital Ocean affixed ENV_SILENT to the start command. I haven't seen any other cloud provider with such precision.

ENV_SILENT=true npm start
Enter fullscreen mode Exit fullscreen mode

What I learned about deployment

Digital Ocean will fail to deploy a Node.js app without a package-lock.json. Funny right? I wonder why the lock file is ignored in the .gitignore of some projects.

Also, if tls host is excluded from ioredis' config, it will fail to connect to a Redis server secured by SSL.

  prod: {
    host: Env.get("REDIS_HOST"),
    port: Env.get("REDIS_PORT"),
    password: Env.get("REDIS_PASSWORD"),
    db: 0,
    keyPrefix: "",
+   tls: {
+     host: Env.get("REDIS_HOST"),
+   },
  },
Enter fullscreen mode Exit fullscreen mode

In the next post of the series, we'll look into a step-step process of deploying the game on Digital Ocean.

Top comments (0)