Siêu thị PDFTải ngay đi em, trời tối mất

Thư viện tri thức trực tuyến

Kho tài liệu với 50,000+ tài liệu học thuật

© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Instant messaging systems
PREMIUM
Số trang
721
Kích thước
5.4 MB
Định dạng
PDF
Lượt xem
1079

Instant messaging systems

Nội dung xem thử

Mô tả chi tiết

Dreamtech

Software Team

Instant

Messaging Systems

Wiley Computer Publishing Timely. Practical. Reliable.

Create Tomorrow’s Instant Messaging Applications Today

Complete source

code and design to

create your own

IM applications

Take an In-Depth Look at Professional￾Grade Instant Messaging Applications

• Java instant messaging server

module

• C# instant messaging server module

• Java instant messaging client module

• C# instant messaging client module

• J2ME mobile client extension

• Integrate instant messaging

applications with web services

• More than 14,000 lines of

documented code

Programming $49.99 USA/$74.99 CAN/£39.99 UK

DREAMTECH SOFTWARE INDIA,

INC., is a leading provider of

corporate software solutions.

Based in New Delhi, India, the

Dreamtech software team has

more than 50 years of combined

software engineering experience.

The CD-ROM features:

• Jabber-compatible instant

messaging system, in both Java

and C# versions, with a J2ME

mobile extension

• Java 2 Software Development

Kit Standard Edition, version 1.4

for Windows

• Java 2 Platform, Micro Edition,

Wireless Toolkit 1.0.3

• Forte for Java, release 3.0,

Community Edition

• Tomcat

• Xerces

• kXML

Note: All software tested at the

Dreamtech Software Research Lab

In this unique guide, a crack team of

software engineers delivers the

programming solutions and source code

you need to jump start a Java- or C#-

based instant messaging project using

the Jabber protocol. With flow charts

and line-by-line analysis of a profes￾sional-quality instant messaging

system, they show you how to solve

typical IM programming challenges —

and create your own Jabber application

using Java or C#, Web services, XML,

ADO.NET, J2ME, and other cutting-edge

technologies.

Visit our Web site at www.wiley.com/compbooks/

Instant Messaging Systems

Dreamtech Software Team

INCLUDES

CD-ROM

*85555-BBABFb ,!7IA7G4-fejfdd!:p;o;t;T;T

ISBN: 0-7645-4953-7

Instant Messaging

Systems

Cracking the Code™

Dreamtech Software Team

Wiley Publishing, Inc.

Best-Selling Books • Digital Downloads • e-Books • Answer Networks •

e-Newsletters • Branded Web Sites • e-Learning

Instant Messaging Systems: Cracking the Code™

Published by

Wiley Publishing, Inc.

605 Third Avenue

New York, NY 10158

www.wiley.com

This book is printed on acid-free paper.

Copyright © 2002 by Wiley Publishing, Inc. All rights reserved.

Published by Wiley Publishing, Inc.

No part of this publication may be reproduced, stored in a retrieval system or transmitted in any

form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise,

except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without

either the prior written permission of the Publisher, or authorization through payment of the

appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA

01923, (978) 750-8400, fax (978) 750-4744. Requests to the Publisher for permission should be

addressed to the Permissions Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd.,

Indianapolis, IN 46256, (317) 572-3447, Fax: (317) 572-4447, E-Mail:

[email protected] publication is designed to provide accurate and authoritative

information in regard to the subject matter covered. It is sold with the understanding that the

publisher is not engaged in professional services. If professional advice or other expert assistance

is required, the services of a competent professional person should be sought.

Wiley, the Wiley Publishing logo, and Cracking the Code are trademarks or registered trademarks

of Wiley Publishing, Inc., in the United States and other countries, and may not be used without

written permission. All other trademarks are the property of their respective owners. Wiley

Publishing, Inc., is not associated with any product or vendor mentioned in this book.

Library of Congress Control Number: 2002106774

ISBN: 0-7645-4953-7

Printed in the United States of America.

10 9 8 7 6 5 4 3 2 1

1B/QW/QU/QS/IN

Dreamtech Software India Inc., Team

[email protected]

www.dreamtechsoftware.com

Dreamtech Software India Inc. is a leading provider of corporate software solutions. Based

in New Delhi, India, the company is a successful pioneer of innovative solutions in e-learning

technologies. Dreamtech’s developers have more than 50 years of combined software￾engineering experience in areas such as Java; Wireless Applications, XML, Voice-based

solutions, .NET, COM/COM++ technologies, Distributed Computing, DirectX, Windows

Media technologies, and security solutions.

About the Authors

Vikas Gupta is co-founder and president of Dreamtech Software. He is engaged in developing

and designing new technologies in wireless applications, e-learning, and other cutting-edge

areas. He is also the Managing Director of Wiley Dreamtech India (P) Ltd.

Avnish Dass, co-founder and CEO of Dreamtech Software, is a talented and seasoned

programmer who has 15 years of experience in systems and application/database

programming. He has developed security systems, antivirus programs, wireless and

communication technologies, and ERP systems.

Gaurav Malhotra is a software developer at Dreamtech and has advanced-level programming

experience in C, C++, and Java.

Pratul Katyal is a senior software developer at Dreamtech. He has two years of experience in

developing software in C, C++, C#, Visual Basic, and .NET technologies.

Credits

Executive Editor

Chris Webb

Project Editors

Neil Romanosky

Kevin Kent

Technical Editor

N. R. Parsa

Copy Editors

C. M. Jones

Bill Barton

Editorial Manager

Mary Beth Wakefield

Vice President and Executive

Group Publisher

Richard Swadley

Vice President and Executive

Publisher

Bob Ipsen

Vice President and Publisher

Joseph B. Wikert

Executive Editorial Director

Mary Bednarek

Project Coordinator

Dale White

Proofreading

Anne Owen

Indexing

Johnna VanHoose Dinse

To our parents and family and our beloved country, India,

for providing an excellent environment

for creating and nurturing world-class IT talent.

Preface

Ever since its emergence in the early 1990s, the Internet has radically changed the way of

accessing and exchanging information among desktops around the globe. Today, almost every

information-hungry business banks heavily upon the Internet. The success of business in the

21st century depends not only on procuring up-to-date information but also on procuring it fast.

It is in consideration of such a scenario that we have developed the Instant Messaging

application described in this book. Throughout the book, the application is developed in both

C# and Java, the two most popular programming languages at this time. Because the Instant

Messaging application is extensible to both of these languages, it is able to meet the exacting

demands of today’s e-business environment.

What this Book Covers

This book details the technology for integrating an Instant Messaging application with the

Jabber server. It is quite evident that there is jetlag among the Instant Messaging applications

available on the market, especially when it comes to communicating with one other. This book

is the first attempt in developing an application that can be integrated with the Jabber server to

tide-over the barriers of cross-platform communication. The source code provided in the CD

that accompanies this book has been developed with the prime emphasis on the requirements

of the business world. The book has been written with focus on code, and every effort has been

made to keep theory to a minimum. The source code provided in the accompanying CD is

fully tested at the Dreamtech Software Research Lab, India, and is fully operational.

This book gives you complete insight into the design and implementation aspects of the

application. The book begins with an introductory note on Instant Messaging and goes on to

explain how Jabber clients can be built with scope for extension to meet the challenges that are

likely to come up because of the rapid change in technology and increasing customer demands.

Who Should Read this Book

The book addresses programmers and developers of the intermediate to advanced level. It is

meant for IT professionals who are keen to learn this specific technology. The book primarily

targets innovative software designers and programmers and inspires them to impart new

dimensions to the Instant Messaging application presented. IT personnel interested in

exploring the open-source based Instant Messaging model, Jabber, will find this book

informative. Since the application is built using the Java and C# programming languages,

programmers using these two languages are offered an opportunity to sharpen their skills. An

additional advantage offered by the add-on feature of this Instant Messaging application is

that, because the application is built using J2ME, readers across the globe stand to reap the

benefits.

Readers are expected to have a firm grip over technologies such as C# and Java. While

developing the application, the fast emerging concept of Web services has also been

viii Preface

considered. Thus, to understand the book fully, it is mandatory for the reader to have

substantial knowledge of ADO.NET and RDBMS such as SQL or Sybase. Since the

application closely works with the Jabber server and the communication standard of the

application is XML, which has been employed to neutralize the differences arising from the

variety of platforms, thorough knowledge of the XML structure as supported by Jabber is

essential.

The code for the application is supplemented with exhaustive explanations.

How this Book Is Organized

Chapter 1 provides a description of the concept and scope of the Instant Messaging

application and outlines its evolution to the most modern form. While discussing the concept

of an Instant Messaging application, the latest form of the open-source, Instant Messaging

Model (Jabber) is taken up. Since the communication standard of the Jabber server is XML

based, the structure of XML as supported by the Jabber server for communication is provided

in this chapter.

Chapter 2 details the designing process of the application and provides a comprehensive

picture of the Instant Messaging application we intend to develop across the book. This

chapter begins with a briefing regarding the prerequisites for developing the application. After

this, the database design of the application is provided. When database is discussed, it must be

noted that this application uses SQL Server 2000 for maintaining the database. The reader is

therefore required to possess some skill in writing SQL queries and to establish the connection

between the front and back ends of the application. The two modules of the application, the

server and client, are detailed in this chapter, along with design considerations.

The communication that takes place between the server and the client is also discussed in this

chapter. Since our application is integrating with the jabber server, various issues involved in

creating and closing the session with the Jabber server are outlined in this chapter. Since this

chapter involves the core designing of the application, readers such as application designers

can benefit from this chapter by developing their own application based on the approach

assumed in developing this application.

Chapter 3 introduces the basic principles of the Java version of the server module of this

Instant Messaging application. The chapter begins with an introductory note on the Web

service and the methodology involved in building and accessing the Web service. The

development phase of the server module is also discussed in this chapter. Since our application

works closely with the Jabber Instant Messaging model, the communication norms between

the server module and the Jabber server have been clarified. Further, the role of the server in

parsing and processing various client requests and the way the server interprets the messages

flowing from the Jabber side have been detailed in this chapter. As mentioned earlier, since

Web services are brought up in this chapter, the various Web methods deployed in our

application are also discussed in this chapter. Apart from detailing the entire server module of

Preface ix

the application, the use of IBM Xerces XML parser and the principle of server programming￾socket and multithreading have been explained in this chapter.

Chapter 4 covers the C# version of the server module of the application. The chapter begins

by laying down the requirements for developing the server. Various Web services used by the

server module are discussed in this chapter, along with the techniques involved in creating and

accessing the Web service. Since the Web service involved in our application handles the task

of retrieving data from the database, the reader must have sufficient knowledge of ADO.NET

and SQL Server 2000. Some familiarity with socket and thread programming is also needed.

Those who possess network-programming skills stand to gain an edge over those who do not.

Since the server module communicates with the Jabber server on one hand and with the client

module on the other, the communication of the server module with the Jabber server and the

client module is presented in this chapter. Also, responses of various Web methods handled by

the server module have been addressed this chapter. Toward the end of this chapter, the

working of the various Web methods involved in our application have been discussed briefly.

The Java version of the client module for the Instant Messaging application is discussed in

Chapter 5. The chapter begins with an introduction to client programming, which presents

guidelines for developing the client module for the application. It is appropriate to mention

here that the reader must have sufficient knowledge of Swing class, as it is used extensively

while creating the GUI for the client module. Later, how the client module establishes the

connection with the server and delivers various kinds of requests is explained in this chapter.

The responses generated by the server module against the request made by the client module

have also been separately presented in this chapter. The reader must be familiar with the

concept of the socket and thread classes and the working and usage of the IBM Xerces parser

for establishing the connection with the server.

Chapter 6 of this book covers the C# version of the client module for the Instant Messaging

application. To appreciate this chapter fully, the reader must be equipped with a sound

knowledge of socket and thread classes. This chapter begins with an introduction to client

programming, which apprises the reader about the scope of client programming. Following

this, the server module is explained. To realize the technique involved behind establishing the

connection with the local server, the reader must be familiar with thread and socket classes.

Since the client module is the origin of all requests, the various types of requests delivered by

the client module and the processes involved in delivering the requests are presented in this

chapter. The parsing of various server responses is carried out by the in-built parsing facility

provided by the XML Document class present in the C# environment.

In Chapter 7, the add-on feature of the application is detailed. The Instant Messaging

application is enhanced to bring handheld devices within its range. The client module of the

Instant Messaging application is adapted to suit handheld devices. To program and understand

the working involved in the background, the reader must be thorough with programming

methodology that uses J2ME. Since J2ME programming is specially meant for handheld

devices, programming for J2ME is outlined in this chapter, along with details of the relevant

x Preface

basics. The limitations of J2ME as a highly stripped-down version of J2SE are also discussed

in this chapter. For programming in J2ME, the reader must be familiar with the stream

connection class, an optimized version of the socket class. Since handheld devices based on

J2ME have the limitation of sparse memory, the parser required for parsing the XML-based

responses must be of such a kind as would work optimally under low-memory conditions. One

such parser, well suited to accomplish the task under these circumstances, is kXML.

NOTE: All of the source code and line-by-line code explanations for Chapter 7 can be found on this

book’s companion CD-ROM.

Companion CD-ROM

The CD-ROM serves to supplement the book. The entire source code to create an Instant

Messaging System using both Java and C# is provided on the CD-ROM, as well as the

development tools that are required to build the application. Apart from this, a complete e￾book version of the book is incorporated in the CD-ROM.

Acknowledgments

We acknowledge the contributions of the following people for their support in making this

book possible: V.K. Rajan, Asim Chowdhury and Priti, for their immense help in coordinating

various activities throughout this project; Hema Sharma, Manish N. Srivastav, technical

writers, who contributed to developing the content of this book; and Deepak Kumar Sharma,

Pankaj Kumar, Yashraj Chauhan, and Pramod Sharma: a team of programmers of Dreamtech

Software India, Inc. who contributed to the development of software for this book.

Contents

Preface ............................................................................................................ vii

Acknowledgments............................................................................................xi

Chapter 1: Introduction to Instant Messaging ..............................................1

A Brief History of Instant Messaging........................................................................................ 1

The Advantages of Instant Messaging....................................................................................... 2

The Need for Instant Messaging................................................................................................ 2

The Future of Instant Messaging ............................................................................................... 3

Jabber Instant Messaging Model ............................................................................................... 3

Introduction to the Instant Messaging Application.................................................................... 7

Required Programming Techniques ........................................................................................ 10

Summary.................................................................................................................................. 14

Chapter 2: Designing the Instant Messaging Application ..........................15

Application Design Considerations ......................................................................................... 15

Database Design Considerations.............................................................................................. 16

Server Module Design Considerations .................................................................................... 16

Client Module Design Considerations..................................................................................... 36

Application Communication Standards ................................................................................... 40

Issues Involved in Creating the Session................................................................................... 45

Issues Involved in Closing the Stream..................................................................................... 46

Summary.................................................................................................................................. 47

Chapter 3: Instant Messaging Server (Java) ...............................................48

Java Web Services ................................................................................................................... 48

Server Development ................................................................................................................ 56

Inside the Server Application .................................................................................................. 63

Inside Java Web Services ........................................................................................................ 91

xiv Contents

Technical Documentation ...................................................................................................... 100

Summary................................................................................................................................ 211

Chapter 4: Instant Messaging Server (C#) ................................................ 212

Web Services ......................................................................................................................... 212

Developing the Server............................................................................................................ 217

Inside the Server Application................................................................................................. 222

Inside a Web Service ............................................................................................................. 237

Technical Documentation ...................................................................................................... 242

Summary................................................................................................................................ 333

Chapter 5: The Instant Messaging Client (Java) ...................................... 334

Basic Implementation of the Client ....................................................................................... 335

Establishing a Connection with the Local Server .................................................................. 339

Programming Client Requests ............................................................................................... 341

Handling Responses............................................................................................................... 357

Technical Documentation ...................................................................................................... 371

Summary................................................................................................................................ 493

Chapter 6: Instant Messaging Client (C#)................................................. 494

Client Module Tasks.............................................................................................................. 494

Server Responses ................................................................................................................... 508

Technical Documentation ...................................................................................................... 519

Summary................................................................................................................................ 623

Chapter 7: Enhancing Instant Messaging.................................................. 624

Introduction to J2ME ............................................................................................................. 624

Design Techniques................................................................................................................. 632

Programming Client Requests ............................................................................................... 645

Handling Responses............................................................................................................... 650

Summary................................................................................................................................ 655

Appendix A: What’s on the CD-ROM ....................................................... 657

Appendix B: Instant Messaging Software Resources ............................... 667

Index .............................................................................................................. 669

Sun Microsystems, Inc. Binary Code License Agreement........................ 685

Tải ngay đi em, còn do dự, trời tối mất!