Results 1 to 2 of 2

Thread: Multi-chatroom

  1. #1
    Mr.Beans's Avatar
    Mr.Beans is offline Senior Member
    Join Date
    Apr 2009
    Virginia Beach, Virginia
    Rep Power

    Default Multi-chatroom

    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?


    Mr. Beans

  2. #2
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Cambridge, UK
    Rep Power


    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.

    Possible architectures:
    - 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

Similar Threads

  1. Multi Client TCP or UDP
    By hunterbdb in forum Networking
    Replies: 8
    Last Post: 10-17-2008, 04:10 AM
  2. chatroom entrance denial
    By girlie34 in forum New To Java
    Replies: 2
    Last Post: 06-09-2008, 06:01 PM
  3. How come multi thread don't look like it?
    By jkhoa in forum Threads and Synchronization
    Replies: 1
    Last Post: 09-22-2007, 04:25 AM
  4. Axiomatic Multi-Platform C 1.6.3
    By levent in forum Java Software
    Replies: 0
    Last Post: 06-05-2007, 11:49 AM

Posting Permissions

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