Smack4.1 android client connection for openfire server

Hi All,

I want to develop chat app in android.

So, I am using smack4.1 version. But i am unable to connect openfire server(which is located my local) using smack4.1.

Could you please provide sample code for connecting openfire server from android client?

And could you provide link for smack4.1 API.

Thanks in advance…

Have a look at this page: https://github.com/igniterealtime/Smack/tree/master/documentation

@Kinderen

Thanks for you reply.

I used below code:

XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()

.setUsernameAndPassword(username, password)

.setServiceName(“localhost”)

.setHost(“10.42.0.3”)

.setPort(5222)

.build();

AbstractXMPPConnection conn2 = new XMPPTCPConnection(config);

try {

conn2.connect();

} catch (SmackException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (XMPPException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

But i am unable connect to the openfire server.

Could you please hemp me? I really hanged here.

I am using Eclipse IDE and android 4.4.2.

One Question:

Is it possible to make android chat app using openfire server?

-also need to insert users from android client etc…

I really need some help…

Thanks

.setServiceName(“localhost”) Servicname is your server name as Openfire Server Information

XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()

.setHost(“10.42.0.3”)

.setPort(5222)

.setServiceName(SERVECE_NAME)

    .setUsernameAndPassword(USERNAME, PASSWORD)

.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)

.setDebuggerEnabled(true).build();

Is it possible to make android chat app using openfire server?

Any XMPP server can, but for me Openfire has a better and easy to use control panel, more reliable and support most of the xmpp xep.

https://play.google.com/store/apps/details?id=com.yahala.messenger

this app is using smack 4.1 and open fire 3.10

-also need to insert users from android client etc…

To create accounts use Account manager

@wael

Thanks a lot for your valuable information…

@Weal,

I am using below code to send message but i am unable find it is working or not.

->logged into user ‘test1’ and ‘test2’ is roster item of test1.

below is the code to send message to test2:

ChatManager chatManager = ChatManager.getInstanceFor(mConnection);

Chat newChat = chatManager.createChat(“test2”);

newChat.sendMessage(“offline Howdy!”);

-> please tell me how to find the message sent or not.

-> i which table messages were stored?

Thanks in advance…

@Wael,

I can create users through AccountManager class.

How to retrieve all created users (not roster items).

I searched document but i did not find which methos doing that.

Could you send sample code for that?

Thanks in advance…

Why do you need to retrieve all users on the client side?!

I guess you cant do that, but you can query the server about users using the search form UserSearchManager (Smack 4.1.0 API)

or add the new created account to everyone roaster

I don’t know how to do it in Smack, but there’s a XMPP specification for it:

XEP-0133: Service Administration

I think it’s somehow possible with AdHocCommandManager. You also need to be logged in as an administrator.

@Wael Thanks for the reply.

I think the search form function is working only when the user is logged in.

But i want to validate the user existence while creating/registring the user i.e after connecting the server (but not logged into any user).

Could suggest me how to handle that?

Thanks in advance …