Subscribe to News

Instructions to integrate D2D

Author : Jbuenol

From TechnologicalWiki

Jump to: navigation, search

Follow this instructions to integrate D2D to provide your software development with D2D communications.

1.- Download jar files:

  • Smack is an Open Source XMPP (Jabber) client library
  • Modified Smack library for Android mobile operating system
  • Telefónica I+D Wrapper for Smack

2.- Import both jar files to your classpath

smack.jar is a standard XMPP library that you can also find over the internet XMPPClient.jar is a service wrapper done by Telefónica I+D

3.- Create a new XMPP client instance

    XMPPService xmppService = new XMPPService(String server, int port, String user, String domain, String passwd, Boolean createAccount);
         server = address of the XMPP server (for instance: osami.tid.es)
         port = port where the server is listening (standard port: 5222)
         user = user name (ej: upnp_render_lounge)
         domain = server domain, usually the same as the server address domain (for instance: osami.tid.es)
         passwd = user password
         createAccount = This flag should be set as true at least for the first connection

4.- Subscribe to receive XMPP events and messages (for instance: errors, connecting, login progress, etc)

    xmppService.addXMPPServiceListener(new Listener());

where Listener is a class that implements XMPPServiceListener.

5.- Start client and send a message

    xmppService.run();
    xmppService.sendMessage(String to, String message)

where to is the addressee, and message is the message (obviously)

6.- Parse and process incoming messages

    public void xmppMessageReceived(Message message) {
         String fromName = StringUtils.parseBareAddress(message.getFrom());
         String trace = "[Localization Server | XMPPClient]: XMPP, Message Received:\n" + " From: '" + fromName + "'\n" + " Message: '" + message.getBody() + "'";
         System.out.println(trace);
         log.info(trace);
    }


Return to OSAmI-ES Developments

Main Collaborators