Book Image

Practical XMPP

By : Lloyd Watkin, Steven Watkin, Koelle
Book Image

Practical XMPP

By: Lloyd Watkin, Steven Watkin, Koelle

Overview of this book

XMPP (eXtensible Messaging and Presence Protocol) is a messaging protocol that enables communication between two or more devices via the Internet. With this book, developers will learn about the fundamentals of XMPP, be able to work with the core functionality both server-side and in the browser, as well as starting to explore several of the protocol extensions. You will not only have a solid grasp of XMPP and how it works, but will also be able to use the protocol to build real-world applications that utilize the power of XMPP. By the end of this book, you will know more about networking applications in general, and have a good understanding of how to extend XMPP, as well as using it in sample applications.
Table of Contents (11 chapters)
Free Chapter
1
1. An Introduction to XMPP and Installing Our First Server

Connecting the clients


Our approach has been bottom-up rather than top-down: first we built the game, then we built the message handlers, and now it's time to bring in the client but all of the pieces are coming together. Next, we want to connect two players so that two people can play XMPPong! First, we need those two players to have unique JIDs, so we need to let each player log into the game.

First, we need to create some accounts so that multiple people can log into the game. Let's create accounts for two players, Marty and Jennifer:

sudo prosodyctl adduser marty@localhost
sudo prosodyctl adduser jennifer@localhost

Tip

For simplicity, I made Marty's password m and Jennifer's password j.

Next, we need to let Marty and Jennifer log into their respective Pong clients. We'll need to extend index.ejs with a couple of input fields to let our players enter their username and password, and we'll need to extend pong.js to accept the new username and password combination and use that to log into...