Results 1 to 1 of 1
  1. #1
    Rylogy is offline Member
    Join Date
    Feb 2012
    Posts
    8
    Rep Power
    0

    Question Help! Trying out the Smack library to make a google chat client.

    Hello everyone,

    Yesterday I started out a small program, for fun and to practice some java(and hopefully get better at it). Well I'm utilizing the Smack library Ignite Realtime: Downloads , since Google uses XMPP. I need some suggestions on how to make my list populate and update in a much preferable way. Right now my list updates by just appending that someone's status became available, so it never erases anything, it just keeps throwing down updates infinitely. Does anyone know how can I make the code for this 100x better? I've been trying out different things, but I'm no pro, therefor, being unsuccessful. Originally I had my list just put out all my contacts, but then I can't know who's online, and who's not. Also, contacts show somewhat strangely, but I can always cut the extra info out of the string before putting it on the list.

    Should I just try to use a tree instead?


    This is the code I'm using for appending the user to the jList

    Java Code:
     public void presenceChanged(Presence presence) {
                    System.out.println("Presence changed: " + presence.getFrom() + " " + presence);
    
                    model.addElement(presence.getFrom().substring(0, presence.getFrom().indexOf('/'))+" - "+presence);
                    }
    This code is what I was using for showing everybody in my friends list in my jList. I messed up something and didn't bother fixing it because I was trying to find a better way of getting my friend's status(Available, Away, Busy, etc etc) updated in my jList

    Java Code:
        private void UpdateList() {
            //Roster roster = connection.getRoster();
            int pos = jList1.getModel().getSize();
            model.removeAllElements();
            roster.setSubscriptionMode(Roster.SubscriptionMode.accept_all);
            for (RosterEntry entry : entries) {
                //Doesn't work
                if (!roster.getPresence(entry.getUser()).equals("unavailable")) {
                    model.add(pos, entry.getUser());
                    pos += 1;
                    // model.addElement(entry);
                    System.out.println(entry);
                }
            }
        }
    Any help will be much appreciated. Thanks for your time.

    (I don't know why the attachments are not working for me, so I put the project and the Smack files in a *.zip)
    smack_3_2_2.zip
    Last edited by Rylogy; 03-22-2012 at 04:58 AM. Reason: Edited to show some code

Similar Threads

  1. Chat client with IRC
    By lok pun in forum Networking
    Replies: 3
    Last Post: 09-06-2011, 06:48 AM
  2. Chat Client using Smack API
    By sQu3aKy in forum Networking
    Replies: 0
    Last Post: 05-01-2010, 02:40 AM
  3. Need help with chat client
    By the_flirt in forum Networking
    Replies: 4
    Last Post: 04-23-2010, 03:49 PM
  4. Chat Client
    By Jessi34 in forum New To Java
    Replies: 5
    Last Post: 12-09-2009, 03:49 PM
  5. Help with chat client program
    By srivigneshwar in forum New To Java
    Replies: 1
    Last Post: 04-03-2009, 06:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •