0
votes

I am trying to create an XMPP client via the Smack library for my android app. The goal is to use GCM-XMPP in my implementation of chatting functionality in my app. From what i've been reading I could use Smack classes such as ChatManager, Chat and Message to create chats between users and also to add chat message listeners. On the other hand, i see that i can do the same i did with the ChatManager, Chat and Message classes using packets in order to create stanzas. From what I understand from GCM documentation, these stanzas will be needed to verify ACK and NACK messages between my app server and GCM CCS servers. Please correct me if I am wrong. It seems to me that creating these packets/stanzas will be more useful once i implement GCM functionality in my chat app.

Also, I still dont understand the role of OpenFire. I have OpenFire installed in my Localhost for testing purposes. To me it seems more like an interface where I can debug chat errors created by the Smack classes. Should this OpenFire be opened in my computer while I test my app chat functionality. I've downloaded OpenFire already and it created the necessary tables in my localhost database.

There's also some code that I am trouble understanding its parameters:

XMPPTCPConnectionConfiguration.Builder configBuilder = XMPPTCPConnectionConfiguration.builder();
configBuilder.setUsernameAndPassword("username", "password");
configBuilder.setResource("SomeResource");
configBuilder.setServiceName("jabber.org");
AbstractXMPPConnection connection = new XMPPTCPConnection(configBuilder.build());
connection.connect();
connection.login();

In the above code, what should be "username" and "password". Should it be the username and password used to log in to my localhost, or a username and password I am using to identify myself as a chatter in my app? What about .setServiceName("jabber.org")? Should I set 10.0.2.2 in here since I am using localhost tested via android emulator? Should I type OpenFire? And when this happens: connection.connect() , where is this connection connecting to? OpenFire or Localhost? Where is it login into?

Any advice will be appreciated

1

1 Answers

1
votes

As mentioned on their site:

Openfire is a real time collaboration (RTC) server . It uses the only widely adopted open protocol for instant messaging, XMPP (also called Jabber).

In order to make calls from the app server to GCM server, you can follow HTTP or XMPP protocol. HTTP supports downstream (gcm to client) messages only. XMPP supports both downstream and upstream (device to gcm, then from gcm to server) messages. This is where Openfire comes in.

In the above code, what should be "username" and "password"?

username - the username or authorization identity

password - the password or token used to authenticate

What about .setServiceName("jabber.org")?

Set the resource to use. If resource is null, then the server will automatically create a resource for the client. Default resource is "Smack".

where is this connection connecting to?

This connects to OpenFire.

Should I set 10.0.2.2 in here since I am using localhost tested via android emulator?

ports are set in .setPort("8222") part of the XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder().

More of the Getting Started guide here.

Now get started with an XMPP tutorial.