Chapter 6.  Building a Chat Application

In this chapter, we will build a real-time chat application usingWebSocket. You will learn how to use the Ratchet framework to build standalone WebSocket and HTTP servers with PHP and how to connect to WebSocket servers in a JavaScript client application. We will also discuss how you can implement authentication for WebSocket applications and how to deploy them in a production environment.

The WebSocket protocol

In this chapter, we'll be working extensively with WebSockets. To fully understand the workings of the chat application that we're going to build, let's first have a look at how WebSockets work.

The WebSockets protocol is specified in RFC 6455 and uses HTTP as the underlying transport protocol. In ...

Get PHP 7 Programming Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.