Private Chat functionality for basic server

Dear all

Firstly i hope this is the best forum for my question.

I've written a basic chat server and client. The server recieves strings messages, and broadcasts them to everyone connected to it. I was wandering, sticking with exchanging Strings over the connection, what ways could I implement a private chat facility so one client could choose to send a message that would only be seen by one chosen user?

Dwarfer

[441 byte] By [Dwarfera] at [2007-11-27 9:13:53]
# 1
protocol
hiwaa at 2007-7-12 22:01:39 > top of Java-index,Java Essentials,Java Programming...
# 2
Chuck most of it out. Someone's already done it better than you (and me, and most people - don't take offence!), use that. Google for the Smack library, it's what you want
georgemca at 2007-7-12 22:01:39 > top of Java-index,Java Essentials,Java Programming...
# 3

Hi georgernc

I completly agree with you. I had originally used the smack api to create a client that talked with an openfire server, however was told (as i'm doing this to create an experiement for a project) that what i was writing was too 'heavy', as there was no need for using things like rooms and roosters) which to be honest is probably true.

So i went back to just writing a very basic server, with not authentication or security (i don't think i really need security as it will never be used outside of a closed network, and even then it will only be used for short periods of time) that just listens for a connection on serverSocket.accept(), reads from it when there is a message(String) arrives and then broadcast that mesage to all those connected to the server.

I'm not too sure how to progress in setting up the private chat facility without using smack and openfire (as i've been told not too). I'm going to get cracking and start playing around and see what i can come up...

Dwarfera at 2007-7-12 22:01:39 > top of Java-index,Java Essentials,Java Programming...
# 4
Ok i've solved the problem by using a hashMap where I map client nicknames to PrintWriters. This way i can have a private chat.Dwarfer
Dwarfera at 2007-7-12 22:01:39 > top of Java-index,Java Essentials,Java Programming...