Lakeside
Lakeside

Reputation: 35

Writing a Java Chat Program (Need Advice)

I'm looking to write a chat program in Java that would have functionality along these lines.

  1. Clients connect to a Server
  2. The Server keeps a list of those connected and make sure their usernames are unique
  3. A Client can request a private chat where the clients would connect directly and NOT through the server.

My question is how would you implement #3? Would you need to make new sockets?

Upvotes: 0

Views: 104

Answers (1)

Jakkra
Jakkra

Reputation: 651

Let the server handle all chats. Make your own "protocols" so your client sends a package containing both the message and destination (user). This can be done with either sending Strings with information you can parse or whole objects. This way it's also pretty easy to create groups with certain users in, all handled by the server.

Upvotes: 1

Related Questions