Multi-terminal real-time communication scheme of mobile phone based on XMPP protocol

Source: Internet
Author: User
Tags rfc file transfer protocol silverlight

I. Development background 1, international background

With the rapid development of Internet technology, instant communication has become a widely used mode of communication. 1996 Mirabilis Company launched the world's first instant messaging system ICQ, less than 10, instant communications (Instant Messaging, referred to as IM) to develop into one of the most popular web applications. Especially in recent years, the rapid development of instant communication, the function of increasingly rich, it is no longer a simple chat tool, it has developed into a set of communication, information, entertainment, music, television, games, e-commerce as one of the integrated information platform.

2. Domestic background

At present, domestic and foreign timely communication software im (Instant Messenger) Situation surging, it is unprecedented, im as the following email and the Web one of the most important application of the Internet, for businesses battleground. The domestic situation because of the monopoly of QQ obvious advantages, the surface slightly calm, but actually undercurrent surging. At present, the Fat Penguin Company to occupy the overwhelming advantage of the domestic IM market nearly 80% share, and tightly grasp the low-end market, a large number of users, profitable. Other IM Microsoft MSN (WLM), NetEase Popo, Sina UC, TOM Skype, Google gtalk share is more tragic, there are Yahoo Instant Messenger, AIM, ICQ and rumors of Baidu im and Sohu search Q and some of the current is not known as the Xiaonei School pass, Lava-lava and so on, and so on, where in the domestic call on the number of Internet enterprises, almost no do not push IM, and even China Mobile are pushing Fetion, hoping to get a cup of soup. However, these instant communications are not interoperable and limit the user's expansion.

3. Why Choose XMPP Protocol

Although there are many real-time communication software, they can not be interconnected and hinder the continued expansion of the timely communication users. Therefore, in the current stage of various even communication services, there is no unified standard, can not achieve the situation of interconnection, and XMPP (extensible Message and Presence Protocol) protocol, the realization of the entire timely Communication service agreement interoperability. With this agreement, the use of any one organization or individual, even if the communication services, can be accessible to other users of the timely communication services to communicate. Google Talk, for example, launched in 2005, is an XMPP protocol-based, even communications software.

There are currently four types of protocols for IM Instant Messaging:

1. Instant Information and Space Protocol (IMPP)

2. Space and Instant Information Protocol (PRIM)

3. Start protocol SIP for Instant messaging and space-balanced expansion processes

4.XMPP protocol: The predecessor of the Protocol is Jabber, we take the XMPP protocol master to implement IM mainly considering that the XMPP protocol is based on XML, which inherits the flexible development in XML environment. This indicates that XMPP is extensible, so XMPP information can be not only simple text, but also can carry complex data and various formats of files, that is, the XMPP protocol can not only be used in communication between people, but also to achieve software and software or software and communication between people, There are gtalk, FaceBook IM, Twitter, NetEase Popo, and other communication tools that support the XMPP protocol, with very good development scenarios.

Just as everything has its own law of development, the progress of technology and products has its own laws.

From germination to chaos, the final standardization is the Basic Law of Internet products. Im with actually developed from email, with email has a lot in common. Let's compare the current situation of e-mail, perhaps some inspiration. E-Mail has now been widely used, no one can question the status of its second application of the Internet (the first application is the Web). e-mail can be widely used in the most critical reason should be email a set of open standards Protocol (including SMTP, POP, IMAP, etc.), anyone can be based on these protocols to open their own email products, whether it is an email server or, e-mail clients are still popular Web forms of email interface, they are based on the same set of standards. In this set of standard framework, each email related vendors occupy the corresponding position of the industrial chain, mutual cooperation and competition, this is a flourishing health competition environment, and this healthy competition ultimately beneficiaries or the majority of users.

XMPP ( was developed by the Jabber Software Foundation and was first implemented on Jabber. The Jabber project was launched by Jeremie Miller in 1998 as a free, open-source project for IM services to MSN and Yahoo!. Because XMPP is an open protocol based on XML schema, it is widely used in IM communication.

The basic part of XMPP has been approved by the Internet Engineering Task Force (IETF) in 2002-2004, which means that XMPP will in the future be like the Internet protocol that we take for granted TCP/IP, HTTP, FTP, SMTP, Pop as an Internet standard; This means that in the future we will use IM as open as using the Web, using email and using FTP. Even a few years later people will take it for granted that 163 of the mailbox can send mail to Hotmail, QQ users can also add gtalk users, people will gradually forget the history of the warlords separatist chaos. This is a revolutionary progress! Im that does not support XMPP will be as narcissistic as IBM's token-ring or forgotten like the DEC net protocol. Thinking back that year Dec NET and IBM token-ring is also how spirited carring ah!

Before XMPP was approved, there were dozens of servers and clients in the world that supported XMPP, as well as millions of of users. The sense of smell-sensitive Google as the open source community and the largest beneficiary of open standards, the first time to feel this trend, so spend a large number of Gaim's author dug Google, so there is a gtalk based on XMPP.

An open standard protocol will lead to a healthier and more competitive product and a more complete industry chain. Of course, the only trend of competition between products is homogeneity, the product development to the late battle only service. This has been fully verified in traditional industries, and the Internet industry cannot escape. As to when the user is choose Gtalk or choose Popo, just like users now choose Gmail or 163 mailbox, can tastes. But im has a lot of room for expansion and value-added services.

Ii. XMPP Protocol Introduction 1, XMPP protocol overview

XMPP (extensible Messaging and Presence Protocol, formerly known as Jabber[1]) is an XML-based open real-time communication protocol, an Internet standard passed by the Internet Engineering Working Group (IETF).

XMPP is an XML-based protocol that inherits the flexibility of development in an XML environment. As a result, XMPP-based applications have super-scalable capability. The extended XMPP can handle the user's needs by sending extended information, as well as creating applications such as content publishing systems and address-based services at the top of XMPP. Furthermore, XMPP contains a software protocol for the server side that enables it to talk to another, making it easier for developers to build customer applications or add functionality to a well-equipped system.

Extensible Message Processing Field Protocol (extensible Messaging and Presence Protocol, XMPP) is an Extensible Markup language (extensible Markup Language, XML) Near-end streaming instant Messaging protocol. It embeds field-and context-sensitive information tags into XML structured data, enabling instant communication between people, application systems, and between people and application systems. The XMPP protocol has been approved as the Internet Instant Messaging protocol standard.

2. XMPP protocol Content

Three roles, clients, servers, and gateways are defined in XMPP. Communication can occur bidirectional between any two of these three. The server also assumes the client information record, connection management and information routing function. The gateway undertakes the interconnection with the heterogeneous instant communication system, and the heterogeneous system can include SMS (SMS), MSN,ICQ and so on. The basic network form is that a single client connects to a single server over TCP/IP and then transmits the XML over it.

3. XMPP protocol Advantages

Open -xmpp agreements are free, open, open, and easy to understand. And in the client, server, components, source code library, etc., have been various implementations.

The standard -Internet Engineering Working Group (IETF) has formally listed Jabber's core XML streaming protocol as a recognized real-time communication and presence technology in the name of XMPP. The technical specifications for XMPP have been defined in RFC 3920 and RFC 3921. Any IM vendor who follows the XMPP protocol can connect to Google Talk.

Proven available -the first Jabber (now XMPP) technology was developed by Jeremie Miller in 1998 and is now fairly stable, with hundreds of developers working on XMPP technology. Tens of thousands of XMPP servers operate on the internet today, and millions of people use XMPP real-time messaging software.

The architecture of the distributed -XMPP Network is very similar to e-mail; the XMPP core protocol communicates by first creating a stream,xmpp to pass the XML data stream with TCP, without a central master server. Anyone can run their own XMPP server, enabling individuals and organizations to take control of their real-time messaging experience.

Security -the server for any XMPP protocol can be independent of the public XMPP network (for example, within an intranet), and reliable security using technologies such as SASL and TLS has been brought into the core XMPP specification.

The power of the extensible-xml namespace allows anyone to build custom functionality on top of the core protocol, and in order to maintain permeability, common extensions are provided by the XMPP Standards Foundation.

good elasticity -xmpp in addition to applications that can be used in real-time communications, it is also useful for network management, content feeds, collaboration tools, file sharing, gaming, remote system monitoring, and more.

diversity -Companies and open source programs that use the XMPP protocol to build and distribute real-time applications and services are distributed in a variety of areas; using XMPP technology to develop software, resources and support sources are diverse, making you not trapped in a "kidnapping" dilemma.

4. XMPP protocol Disadvantage

The data load is too heavy: with the presence of data traffic for servers that typically exceed 70% of the XMPP protocol and nearly 60% of them being repeatedly forwarded, the XMPP protocol currently has a large overhead in the presence of data available to multiple recipients. The new protocol is being studied to alleviate the problem.

There is no binary data: The XMPP protocol is encoded as a single long XML file and therefore cannot be provided to modify binary data. Therefore, the file Transfer Protocol uses external HTTP as well. If unavoidable, the XMPP protocol also provides Base64 for all data that is encoded with the file transfer. For other binary data encryption sessions (encrypted conversations) or graphical icons (graphic icons) Use the same method as embedded.

5. XMPP provides Electronic Business card agreement

vcard is an existing, widely used, user personal information storage standard, a bit like an electronic business card. The underlying function is to store and retrieve the user's electronic identity, which is expressed in XML, and the storage of the data depends on the implementation of all existing Jabber servers.

6. XMPP System Features

Client/server communication mode, distributed network, simple client, XML data format.

Third, server-side introduction 1, What is OpenFire

OpenFire is developed in Java, and the open source real-time collaboration (RTC) server is based on the XMPP (Jabber) protocol. You can use it to easily build an efficient Instant Messaging server.

OpenFire is easy to install and use, and is managed with the Web. A single server can support tens of thousands of concurrent users.

Because of the open XMPP protocol, you can use various IM client software that supports the XMPP protocol to log on to the service.

2. Why Use OpenFire

A, OpenFire for Java Open Source project

B. Using an open XMPP protocol

C, there are a variety of non-system version

D. Using socket communication

E, a single server can support tens of thousands of concurrent users, build a distributed cloud server can easily provide a large number of concurrent users.

F, Socket long connection

G, server stability

H, provide the interface, can develop their own plug-in

3. Build server under Windows

JDK1.6 + openfire for Windows + Mysql5.5 + Tomcat6

4. Build server under Linux

JDK1.6 + openfire for Linux + Mysql5.5 + Tomcat6

5, Mac build server four, client introduction 1, Mobile Client

A , Forandroidclient

Mobile Login Interface

Mobile IM Contact list

Mobile phone users chatting with PC client users

mobile phone users and Web End user Chat  

B, formobileclient

C, foriphoneclient

D, Forsymbian


2. PC Client

A, Sparkforjava (opensource)

PC End User Login interface

PC -End IM Contact Interface List

PC-side user and mobile user chat interface

PC-side user chats with web-side users

B, sparkforc# (opensource)

2. Web Client

A, RIA (Flex and Silverlight)


C , Web2.0

Web -Side Login

Web End and PC Chat

Web-side chat with mobile phone

V. Environment Construction 1, install JDK

Download the JDK on the website and install it properly, and set the environment variables after the installation is complete.

2, Installation OpenFire

Download the OpenFire, and install it normally by default.

3. Install MySQL

Download install MySQL, specify the user name and password for MySQL, and the encoding used by the database. Determines whether remote access to the database is allowed.

4. Installing Apach Tomcat

Download the Tomcat server under the Apach Foundation and unzip the installation.

5. Configure the Environment

Log in to the OpenFire Server console and set up the relevant information. such as: ports, plugins and so on.

and deploy the project to Apach Tomcat.

6. Installation Project

1, Forandroid

Download the Android Project xmppclientforandroid.apk from Tomcat and install it on your phone.

2, Forpc

Download the PC's Project Spark.exe from Tomcat and install it on your phone.

3, Forweb

Open the project in Tomcat and run the login directly.

After clicking Run:

7. Set the server address

Forandroid, Forpc, and forweb all provide a place for server address settings. The default OpenFire port is 5222. (except that the Silverlight port must be 4502-4532)

8. Registered Users

Users can be registered directly on the server side, or they can be registered on the client.

9, the corresponding operation

corresponding to the Instant messaging operation.

Vi. Project Demo 1, server-side settings

A , OpenFire Control Desk

Server main interface:

Console Main interface:

Console internal management:

Users/ Group Management:

Session Management:

Chat Management:

A, Mysql Database

database table structure:

2. Client Settings

A, forandroid

B, Forpc

C, Forweb

Seven, multiple, multi-terminal instant Messaging 1, QQ, FaceBook, Twitter, MSN Messenger, Yahoo Messenger, AIM, Gadu-gadu, ICQ, Google talk, Popo

Study different communication protocols and integrate the commonly used IM in the Internet so that users do not have to install too many chat software in the operating system.

2, PC, Pad, Phone, Web

Users can chat via PC, Pad, Phone, Web, and any other client.

Viii. Solution 1, one application, multiple types of accounts can be logged in at the same time.

Similar to live Mail, no account can only chat with friends under this account.

Some foreign software (Palringo, Trillian) to achieve this function.

2, an application, an account can chat with other types of account friends.

XMPP IM with non-XMPP the other IM Interconnection Method: If the other party is not a user in the XMPP system, it is necessary to set up a protocol conversion gateway on the Enterprise IM server. An IM protocol conversion gateway is erected on an IM server in XMPP, subject to the RFC3922 protocol, which specifies the mapping of XMPP to public display and instant message (CPIM). This describes a user's communication with MSN users. Before communicating with MSN users, enterprise IM users first set up an MSN user to the XMPP-MSN protocol switch gateway (tell MSN Users and passwords to the gateways), and now the gateway can use this MSN account with MSN System to communicate. After the enterprise IM user who is bound to the MSN user logs on to the enterprise IM server, the Protocol conversion gateway returns the MSN account Friend's MSN accounts to the user and maps them to the local XMPP account. Users can now communicate with MSN account users just as they do with local XMPP users.

Ix. Full-Text summary map

This article refers to a lot of network information, forget the article link. Apologize to them first.

Multi-terminal Instant Messaging scheme based on XMPP protocol. pdf


Multi-terminal real-time communication scheme of mobile phone based on XMPP protocol

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.