IN THIS ARTICLE

    Waving Hand

    Good News! We’ve launched an all new Chat Resource Center.

    We recommend checking out our new Chat Resource Center, which includes overviews, tutorials, and design patterns for building and deploying mobile and web chat.

    Take me to the Chat Resource Center →

    In our previous blog post, we built a multiplayer game lobby with a basic chatroom. However, we couldn’t see who was actually sending each message in the chatroom and all users in the chatroom were anonymous.

    In this blog post we’ll change that. We’ll walk you through differentiating messages from different users by adding users and usernames to our chatroom. We’re going to continue working with the same code from the previous part.


    We’ve now covered both building a multiplayer game lobby with a chatroom and the different ways we can use matchmaking to connect two different users. Here’s what we’ve covered so far:

    This blog post is Part Two of PubNub Developer Evangelist Ian Jennings‘s series on creating a multiplayer game with JavaScript.


    Generate Random Chatroom Usernames

    chatroom

    You’ll first need to sign up for a PubNub account. Once you sign up, you can get your unique PubNub keys in the PubNub Developer Portal. Once you have, clone the GitHub repository, and enter your unique PubNub keys on the PubNub initialization, for example: