0

i m try to connecting to nimbuzz chat with opensource xmpp library i've been able to figure out that the nimbuzz chat protocol is XMPP, i've ventured into trying to connect and chat with an XMPP client library like agsXMPP.

I've been unable so far to connect or do anything, my code so far looks like:

public static void main(String args[])
    {
            Socket s = null;
            try {
                s = new Socket("195.211.49.6", 5222);
            } catch (UnknownHostException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            PrintWriter out = null;
            try {
                out = new PrintWriter(s.getOutputStream());
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            out.println("<stream:stream to='nimbuzz.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>");

            out.flush();

            BufferedReader reader = null;
            try {
                reader = new BufferedReader(new InputStreamReader(s
                        .getInputStream()));
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            String line;
            try {
                while ((line = reader.readLine()) != null) {
                    System.out.println(line);

                }
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            out.println("<iq type='set' xml:lang='en' id='terms' to='nimbuzz.com'><query xmlns='jabber:iq:auth'><username>myusername/username><password>mypassword</password><resource>Miranda</resource></query></iq>");
           out.flush();
            try {
                reader = new BufferedReader(new InputStreamReader(s
                        .getInputStream()));
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            try {
                while ((line = reader.readLine()) != null) {
                    System.out.println(line);

                }
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            try {
                s.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

    }

but i did not connect . any one have idia to how to connect nimbuzz useing xmpp api for send message or chat?

Niraj Thakar
  • 168
  • 1
  • 2
  • 13

0 Answers0