Chat application over xmpp protocol

Hi folk,

Today I’m going to share simple chat application that is based on xmpp protocol.

i know that they have lost of question in your mind about xmpp , so simply i’m start with some definition or basic question

# what is xmpp ?

xmpp is the extensible messaging and presence protocol, a set of open technologies for instant messaging,presence,multi-party chat, voice and video calls, collaboration, lightweight middleware, content syndication,and generalized routing of xml data.

XMPP was originally developed in the Jabber open-source community to provide an open, decentralized alternative to the closed instant messaging services at that time. click here for more detail

# Why xmpp?

#Open standard – its gives you the choice and control about how you access your data and service

#multi platform support – you can create chat application for the multiple platform over the xmpp protocol

# xmpp implementation :

For the xmpp chat application we have to implement chat client and  configure server. firstly we are talking about chat client then we going to implement server configuration.

#Prerequisites

The following assumes that you have already basic knowledge in Android development with android studio

1.Android studio

2.Smack 4.1 library (smack 4.1 supporting android for previous version we need to implement asmack  library)

#Example :

step 1 > Create a project in android studio(File -> New Project(add Application name,project location) -> check phone and teblet and select minimum sdk -> select activity type -> define activity name ->finish) for more detail how to manage a project in android studio click here

add library detail in build.gradle file as below

build_gradle_config

 

step 2 > after adding library into project , now connect to openfire server and login as user

Configuration_and_login

 

above this code example i have disable ssl and DIGEST-MD5 . According to your need you can enable it.

if you want to create user through your application then use AccountManager classto do it as for exp :

Account_manager step 3 > after successfully connected to chat server now create a chat with another user and receive there message

 doChat_createchatmessageListner

Above this code i’ve created doChat method where we need to pass userId(userId withwhome we want to chat) and implement ChatMessageListner to recive user message.

I hope a tutorial is helpful

Thanks for reading 🙂

Advertisements