How to manage many connections?

Hy,

at the moment I’m writing a MultiUserChat with the help of the smack api. Like you know the smack documentation also gives some examples about how to create a connection. But what is the solution if I want to create many connections to my openfire server?

The users should be able to connect to a multi user chat room. So I have a class connection. If a user tries to login a new instance of my class connection will be created. So far so good. But if a new user is coming, the object gets overridden. (privat Connection con;)

So the problem is that always just one user is connected to the server.

What is the best solution to manage many conections to my xmpp server?

…I was thinking about an ArrayList. Would that be the best to handle all the connections?

The next question would be… I want to create a new connection to the server if the user is not already logged in. How can I check if the user is not in logged in or in the room?

Maybe I have a fault in my line of thought?!

I didn’t find a lot on the internet about managing the connections to an xmpp server, hope you can help me. Thank you.

Ok, I found the answer on my own.

Maybe the question was to easy or not relevant?!

Anyway, maybe somebody is interested in the solution…

I’m now using a Arraylist of Connections and it looks like that:

private ArrayList conn = new ArrayList();

The Connection class does the most interactions with the server like connect and disconnect, joining muc rooms and so on.

Oh and for the second question about the login:

I’m using a session which stores the username of the user which uses the service. So it is easy to compare the session username with all the usernames in the Connection Arraylist.