CEO, Tech IT Easy Lab of Pervasive VM Computing +91 9830740684 ([email protected]) A...

12
Soham Sengupta CEO, Tech IT Easy Lab of Pervasive VM Computing +91 9830740684 ([email protected]) A Beginner’s Guide to XMPP

Transcript of CEO, Tech IT Easy Lab of Pervasive VM Computing +91 9830740684 ([email protected]) A...

Page 1: CEO, Tech IT Easy Lab of Pervasive VM Computing +91 9830740684 (sohamsengupta@yahoo.com) A Beginner’s Guide to XMPP.

Soham Sengupta

CEO, Tech IT Easy Lab of Pervasive VM Computing+91 9830740684 ([email protected])

A Beginner’s Guide to XMPP

Page 2: CEO, Tech IT Easy Lab of Pervasive VM Computing +91 9830740684 (sohamsengupta@yahoo.com) A Beginner’s Guide to XMPP.

XMPP : what and why?

Existing Web Technologies have 2 broad categories

Pull (Example HTTP where connection is initiated by Client and initial communication is unidirectional (HTTP Request)

Push (Where communication is initiated by clients but connection is bi-directional, and keeps alive till disconnection or log-out )

Need and utility of (Server) Push: Real time Messaging (IM) like Google Talk, Facebook

chat etc Delicate and urgent information like Stocks quotes that

need be initiated to clients Real time Location tracking News feeds Cricket scores

Page 3: CEO, Tech IT Easy Lab of Pervasive VM Computing +91 9830740684 (sohamsengupta@yahoo.com) A Beginner’s Guide to XMPP.

XMPP a Push Protocol

Extensible Messaging and Presence Protocol

Text and Binary

Messaging

Augmentable

It can send Client

information

In G-talk you find if the other end is typing, entered message or her status like

busy, idle, away etc

Page 4: CEO, Tech IT Easy Lab of Pervasive VM Computing +91 9830740684 (sohamsengupta@yahoo.com) A Beginner’s Guide to XMPP.

Jabber

Jabber may refer to:The original name of the 

Extensible Messaging and Presence Protocol (XMPP), the open technology for instant messaging and presence.

Jabber.org, the public, free instant messaging and presence service based on the XMPP protocol.

Jabber XCP, a commercial product which is an implementation of the XMPP protocol. Acquired by Cisco Systems in 2008.

Page 5: CEO, Tech IT Easy Lab of Pervasive VM Computing +91 9830740684 (sohamsengupta@yahoo.com) A Beginner’s Guide to XMPP.

Smack

1. Smack is an Open Source XMPP (Jabber) client library for instant messaging and presence.

2. A pure Java library

3. It can be embedded into your applications to create anything from a full XMPP client to simple XMPP integrations such as sending notification messages and presence-enabling devices.

4. We learn in next slides how to use Smack and make a simple Java application client for XMPP

Page 6: CEO, Tech IT Easy Lab of Pervasive VM Computing +91 9830740684 (sohamsengupta@yahoo.com) A Beginner’s Guide to XMPP.

Smack: Getting started

1. Pre-requites:a) Java SE 1.4 or above, SDK, language basics and conceptb) An active Internet connection c) At least two Google accounts d) The Jabber Smack API Download Site

2. Step-1a) Have the 2 jar files,

i. Samck.jarii. Smackx.jar

that come with the API in your build path (CLASSPATH)b) We make sure that the two Google id can chat with each

other, i.e. they are friend to each otherc) We make sure we are connected to Internet

Page 7: CEO, Tech IT Easy Lab of Pervasive VM Computing +91 9830740684 (sohamsengupta@yahoo.com) A Beginner’s Guide to XMPP.

Smack Tutorials

Some useful terms: Roster

A list, especially of names : Dictionary meaning While we chat we refer to our Friends in chat list as

Roster

Connect to an XMPP Server1. 5222: default Port for XMPP (used by most of the

providers)2. We connect to talk.google.com with our google (gmail)

id and password

Page 8: CEO, Tech IT Easy Lab of Pervasive VM Computing +91 9830740684 (sohamsengupta@yahoo.com) A Beginner’s Guide to XMPP.

Code Snippets to Connect

XMPPConnection The Java type that represents an XMPP connection It needs a ConnectionConfiguration object to set up The configuration object needs host, port and service name connection.connect() connects to the server & no authentication

(login) done connection.login(user,password) succeeds on an Active Network if

user and pasword are valid, else fails

Page 9: CEO, Tech IT Easy Lab of Pervasive VM Computing +91 9830740684 (sohamsengupta@yahoo.com) A Beginner’s Guide to XMPP.

Connection set up continued…

XMPP Server Port Number User ID Password

My password not shown here

Page 10: CEO, Tech IT Easy Lab of Pervasive VM Computing +91 9830740684 (sohamsengupta@yahoo.com) A Beginner’s Guide to XMPP.

Send a Text Message

XMPPConnection

Text Message

Recipient ID

Chat type message

Add text

Output console and browser notification

Page 11: CEO, Tech IT Easy Lab of Pervasive VM Computing +91 9830740684 (sohamsengupta@yahoo.com) A Beginner’s Guide to XMPP.

Listen For An Incoming Message

Output

Page 12: CEO, Tech IT Easy Lab of Pervasive VM Computing +91 9830740684 (sohamsengupta@yahoo.com) A Beginner’s Guide to XMPP.

References You can study

http://www.igniterealtime.org/projects/smack/http://xmpp.org/about-xmpp/technology-overv

iew/https://peepcode.com/products/xmpp