The Artima Developer Community
Sponsored Link

Java Answers Forum
how to write a messenger with using java?

1 reply on 1 page. Most recent reply: Jul 30, 2008 1:02 AM by Kondwani Mkandawire

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
NG YIN

Posts: 1
Nickname: kira5
Registered: Jul, 2008

how to write a messenger with using java? Posted: Jul 29, 2008 7:48 PM
Reply to this message Reply
Advertisement
May I know how to write a messenger with using java? The messenger need included two functions which are file transfer and add users to join the conversation.


Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: how to write a messenger with using java? Posted: Jul 30, 2008 1:02 AM
Reply to this message Reply
For the FileTransfer bit, refer to Apache FTP API - I think its in Apache Commons. For the Adding of the User, naturally you will want to add a User Object to a Singleton Map identified by some Sort of String.

E.g.
//  Given you have a Pojo called User
private static Map<User> usersLoggedOn = new <User>HashMap();
... ...
 
public static void addToConversation(String login, String password) {
    User user = null;
    if (usersLoggedOn.get(login) == null) {
        user = SomeDataSource.login(login, password);
        if (user != null)
            usersLoggedOn.put(login, user);
    }
}
 
public static Map<User> getUsersLoggedOn() {
    return usersLoggedOn;
}
 
//  SomeDataSource is some persistent storage (could be a database or a file to which you write registered users).
 

Flat View: This topic has 1 reply on 1 page
Topic: How to get classes present in the imported package Previous Topic   Next Topic Topic: how to use sessions

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use