Tic-Tac-Toe is for two players, X and O, who take turns marking the spaces in a 3×3 grid. The player who succeeds in placing three of their marks in a horizontal, vertical, or diagonal row wins the game.
This is a realtime multi-player Tic-Tac-Toe on web- You and your opponent need to play together on separate browsers. You can just open an another browser window to act as your own opponent. Your opponent needs to use the same Game ID by passing it in the URL as a query string.
You (X):
Your opponent (O):
To demonstrate how PubNub publish / subscribe works, scroll a bit to see the bottom section of this page, and watch what message is being published and subscribed!
Let's say, you are playing X.
Each time you click one of the cells, your move is published to PubNub data stream.
Your opponent receives the data by subscribing the message just have been published.
The UI on both browser windows is updated upon each subscribe call.
You are publishing (your move):
{player: ---, position: ---}
You subscribing (all the messages published to PubNub stream):
{player: ---, position: ---}