Book Image

Practical XMPP

By : Steven Watkin, David Koelle
Book Image

Practical XMPP

By: Steven Watkin, David 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 (16 chapters)
Practical XMPP
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
1
An Introduction to XMPP and Installing Our First Server

Preface

XMPP has been around since 1999, and in that time has been rediscovered several times over by generation after generation of programmers. Originally started to unify what was a massively fragmented instant messaging scene, XMPP has continued to show its relevance as new technologies and technology uses emerge.

We'll be making use of the Prosody XMPP server, a fast, resource light system written in LUA, as well as Node.js to write our own projects. The two main libraries we'll be using to interact with XMPP are node-xmpp on the server side and XMPP-FTW, a translation layer between XMPP’s XML messages and JSON, which is massively popular for use in the browser.

Through this book, you'll learn about the core concepts of XMPP, build basic clients that will allow you to interact with the XMPP ecosystem at large, build time-saving bots, and even build an entire custom application using XMPP standards and your own extensions.

The skills you'll learn in this book will allow you to create the next massively popular chat application built on the core standards, through to your own full-fledged Internet of Things (IoT) device that will collect, share, and respond to data from interconnected servers all over the world!

What this book covers

Chapter 1, An Introduction to XMPP and Installing Our First Server. Provides a brief introduction to the history of XMPP and its uses as well as installing and interacting with our first XMPP server.

Chapter 2, Diving into the Core XMPP Concepts, reveals that XMPP covers a vast number of areas but at its core is very simple and extensible. Here we learn about the core concepts so when we come to building our XMPP applications later we understand what's going on.

Chapter 3, Building a One-on-One Chat Bot - The "Hello World" of XMPP, show us how to build a simple chat bot and interact with it via a standard client.

Chapter 4, Talking XMPP in the Browser Using XMPP-FTW, we introduce XMPP-FTW and shows us how to build some basic functionality.

Chapter 5, Building a Multi-User Chat Application, how to  create a very basic multi user chat client in the browser and begin chatting with our XMPP users.

Chapter 6, Make Your Static Website Real-Time, takes a standard static website and add real time data to it pushed via XMPP, making even the dullest website dynamic and exciting!  

Chapter 7, Creating an XMPP Component, shows how to create our first server-side component, which let you develop business logic without modifying the server itself.

Chapter 8, Building a Basic XMPP-Based Pong Game, how to create a simple application, using standard chat messages to convey game state. We also learn about Client DISCO for discovering capabilities of a client connected to a chat server.

Chapter 9, Enhancing XMPPong with a Server Component and Custom Messages, explains how to develop a full-fledged XMPP demonstration application, including a server-side component, an XMPP-FTW extension that allows us to create our own messages, and clients that talk to the server using those messages.

Chapter 10, Real-World Deployment and XMPP Extensions, presents considerations for deploying your app, including security and scalability. These capabilities are described in XMPP Extension Protocols (XEPs), and in this chapter we also take the opportunity to introduce several additional XEPs that describe emerging XMPP features, including Internet of Things and WebRTC.

What you need for this book

The requirements for all sections of this book after fairly minimal. Any computer built within the past five years that supports a recent version of Linux, Mac, or Windows will be sufficient. An up-to-date browser will be required for websocket support, but even then the project is able to fall back to standard HTTP. You machine should have at least 128 Mb of free RAM and the same amount of hard drive space.

Who this book is for

If you want to learn about the fundamentals of XMPP, be able to work with the core functionality both server-side and in the browser, then this book is for you. No knowledge of XMPP is required, or of TCP/IP networking. It's important that you already know how to build applications of some form, and are looking get a better understanding of how to implement XMPP for one or more of its many uses. You should be interested in the decentralized web, know HTML, and know JavaScript and NodeJS. You will probably know JSON, and hopefully XML (this is the native output of XMPP).

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: First we'll install libicu and libexpat-dev.

A block of code is set as follows:

modules_enabled = {
        "roster";
        "saslauth";
        "tls";
        "dialback";
        "disco";
        "version";
        "uptime";
        "time";
        "ping",
        "register";
        "posix";
        "bosh";
};

Any command-line input or output is written as follows:

$ curl https://raw.githubusercontent.com/creationix/nvm/v0.32.0/install.sh | bash
$ source ~/.bashrc
$ nvm install 6
$ node -v

New terms and Important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "The shortcuts in this book are based on the Mac OS X 10.5+ scheme."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.
  2. Hover the mouse pointer on the SUPPORT tab at the top.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box.
  5. Select the book for which you're looking to download the code files.
  6. Choose from the drop-down menu where you purchased this book from.
  7. Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows
  • Zipeg / iZip / UnRarX for Mac
  • 7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Practical-XMPP. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at [email protected] with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.