|
Re: how to write a messenger with using java?
|
Posted: Jul 30, 2008 1:02 AM
|
|
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).
|
|