Were ready discuss the roster info protocol and the user presence protocols
Instant Messaging
in Java
M A N N I N G
Greenwich
|
---|
©2002 by Manning Publications Co. All rights reserved.
|
|||
---|---|---|---|
|
|||
Printed in the United States of America
1 2 3 4 5 6 7 8 9 10 - VHG 05 04 03 02
preface | ||||||
---|---|---|---|---|---|---|
about this book | ||||||
author online |
|
|||||
acknowledgments |
|
|||||
about the cover illustration | ||||||
|
1.2
1.3 | Benefits of the Jabber protocols | 27 |
|
|
---|---|---|---|---|
1.4 | Drawbacks of the Jabber protocols | |||
1.5 | Conclusion |
|
Benefits 35 | I Drawbacks 36 |
|
|
---|---|---|---|
servers 38 |
|
2.2 | The core Jabber protocols | ||||||
---|---|---|---|---|---|---|---|
Message: Delivering data 45 | |||||||
online status 45 | |||||||
2.3 |
|
|
|||||
2.4 | Conclusions | ||||||
|
|||||||
Goals for our server 60 |
|
3.2 | The session pool maintains client connections |
---|
3.4 3.5 |
XML parsing subsystem | |||||||
---|---|---|---|---|---|---|---|---|
|
|
|||||||
|
|
|||||||
Conclusion |
4 | contents | ix | ||||||
---|---|---|---|---|---|---|---|---|
|
||||||||
4.1 | Messaging is the heart of IM |
|
||||||
4.2 | ||||||||
Normal messages 104 | ||||||||
Groupchat messages 106 | ||||||||
Error messages 109 | I | Out-of-band messages 110 | I Reality check: |
one message, many user interfaces 112
5 | 4.3 | Java Jabber client |
|
||||||
---|---|---|---|---|---|---|---|---|---|
Goals 114 | I The client design 115 | ||||||||
model 116 | I Using the client model 123 | ||||||||
4.4 | Conclusions | ||||||||
|
|||||||||
5.1 |
|
||||||||
5.2 | |||||||||
5.3 | Adding groupchat support | ||||||||
Groupchat protocols 138 |
6 | 5.4 | Shortcomings of our server and basic groupchat |
|
||||||
---|---|---|---|---|---|---|---|---|---|
5.5 | Conclusions |
|
|||||||
Info/Query and client registration | |||||||||
6.1 | Info/Query: the catch-all protocol | ||||||||
The IQ protocol 165 | |||||||||
6.2 | Registration creates and manages accounts | 169 | |||||||
User accounts 170 | |||||||||
6.3 | The Jabber server modifications |
|
6.4
x | contents | Client authentication | |||
---|---|---|---|---|---|
7 | |||||
7.1 | Authentication controls account access |
The authentication protocol 191
7.2 | The Jabber server modifications |
|
---|---|---|
7.3 | The Jabber client modifications |
Conclusions 215
8 | Roster and user presence |
|
||
---|---|---|---|---|
8.1 | Roster protocol: presence’s missing piece |
9 | 8.2 | The Jabber server modifications | |||||
---|---|---|---|---|---|---|---|
Representing user presence 224 | |||||||
subsystem 226 |
|
||||||
8.3 |
|
236 | |||||
8.4 | Conclusions | ||||||
9.1 | Creating Jabber-compliant implementations |
|
Setting standards: the Jabber Software Foundation 245 Enforcing standards: Jabber Powered applications 245 Organizing standards: Jabber environments 246
Today’s options for achieving server compliance 247
9.2 | ||||||
---|---|---|---|---|---|---|
Server-to-server communications: federating Jabber domains 248 | ||||||
|
I Deployment of Jabber servers | |||||
|
||||||
services 262 | I Jabber server management 264 | I Adding reliability |
9.3 | Client missing pieces |
---|
9.4 | User agent clients | contents | xi | |
---|---|---|---|---|
|
|
9.5 |
|
|||||
---|---|---|---|---|---|---|
Enterprise Jabber |
|
|||||
10.1 | ||||||
Enhancing Jabber security 273 | I Guaranteed quality | |||||
of service 278 | I Creating system administration tools |
10.4 |
The promise of MOM |
|
||||||
---|---|---|---|---|---|---|---|---|
Examples of Jabber applications |
|
|||||||
|
||||||||
services 293 | ||||||||
Distributed application alternatives to Jabbers | ||||||||
|
||||||||
|
references 369
index 373
xiii
|
---|
Then I came across Jabber. It is open source, and exploits the very best fea-tures of XML, another hot technology. I was familiar with XML and understood the fundamental benefits driving its hype but had yet to see a compelling reason to use XML in my software. Jabber appeared to be that application.
Digging deeper into Jabber revealed a design that was simple and flexible. I’m a firm believer in the KISS philosophy2 so the appeal only grew. I decided to start playing with the technology.
about this book
This book leads the reader in building an IM system using the Java programming language. I believe that the best way of showing how something like instant mes-saging is done in general is to illustrate how it is done with a particular example. Our IM system uses the Jabber protocols and architecture and we’ll cover both in depth as we build our software. Once you understand how the Jabber protocols work to create an IM system, I hope that you will be able to extrapolate your expe-rience to build other IM systems based on Jabber or other protocols if necessary.
xv
xvi |
|
---|
This book is split into three parts. Part 1 introduces IM and Jabber technologies and describes the basic architecture of all Jabber-based systems. In part 2, we dig into the gritty details of the core Jabber protocols and develop Java server and cli-ent software. Finally, in appendix A, I’ve included a condensed reference to the Jabber protocols as they stand at the time of this writing. The Jabber protocols are continuing to evolve so you should check the Jabber website (www.jabber.org) for announcements and the book’s website (www.manning.com/shigeoka) for updated versions of the reference section.
Part 1—Overview
about this book | xvii | |
---|---|---|
|
architecture and protocols. We also examine the raw communication stream between the Jabber server and client to illustrate what “raw” Jabber looks like.
Chapter 4—The Jabber message protocols. Covers the Jabber message protocol and implements support for basic messaging in the server. In addition, we develop a “test Jabber client” to test our evolving Jabber server.
Covers the Jabber presence protocols and Chapter 5—The presence protocols.
Chapter 8—Roster and user presence. With user accounts firmly established in chapters 6 and 7, we’re ready to discuss the roster info/query protocol and the user presence protocols. A user’s roster stores the “buddy list” of subscribers inter-ested in their presence status. The user presence protocols update the user’s pres-ence and subscribe users to other users’ rosters.
Chapter 9—Creating a complete Jabber system. Ties up the loose ends for part 2. There is no way to complete a fully featured or “production ready” server or client within the book. This chapter describes what remains to be done and suggests ways to tackle each problem.
xviii |
---|
How to use this book
I would suggest that you read chapters 1–3 in order to get a firm grasp of Jabber and the software that we build throughout the book. Chapters 4–8 build upon each other. If you are completely unfamiliar with the Jabber protocols it may be a good idea to read through them in the order presented. If you only want to learn the protocols, you can read the first section of each of those chapters as source code is presented at the end of the chapter.
I Technical terms are introduced in italic font.
I Code examples and fragments appear in a fixed-width font.
about this book | xix |
---|
I Many sections of code have annotations which appear in the right margin.
I Some advanced topics are discussed that will not be of interest to beginning programmers. These advanced discussions have a gray background and a black diamond in the margin. Beginners can skip these sections.
Tools: a Java development environment
Building the Java software covered in this book requires four tools. I’ve tried to keep the requirements to a minimum. The following table shows you what tools