Results 1 to 2 of 2
- 05-15-2009, 11:04 PM #1
I'm trying to create a server/client which will be similar to IRC. I want the users to have nick names which they can register. Then the ability for them to join channels (or chatrooms).
What would be the best way to create a server/client with multiple chatrooms?
Should I send which channel to display the message to the server, then let it give it give it to a channel thread which will send the message to all the sockets connected to that channel. Or should I make it so that the user has a direct connection to each channel?
Also how can I associate nicks? Should I also send the name of the person who is sending the message?
How can I associate a socket with a nickname?
- 05-15-2009, 11:16 PM #2
I'd have a separate thread for every connected socket, storing messages in some kind of queue. Then a separate thread sends the incoming messages asynchronously to all other connected sockets.
- Separate ServerSocket and port for each room, plus directory service
- Single ServerSocket and Tag each message with the destination room
Both methods, maintain a list of all sockets in a room. For nicnames, use a similar message tag. Name could be stored in a Map<Socket, String>, Thread.getName(), etc.Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
How To Ask Questions The Smart Way
- By hunterbdb in forum NetworkingReplies: 8Last Post: 10-17-2008, 04:10 AM
- By girlie34 in forum New To JavaReplies: 2Last Post: 06-09-2008, 06:01 PM
- By jkhoa in forum Threads and SynchronizationReplies: 1Last Post: 09-22-2007, 04:25 AM
- By levent in forum Java SoftwareReplies: 0Last Post: 06-05-2007, 11:49 AM