Client Server Chat Program using Java

in #technology7 years ago (edited)

This is some code I wrote in my spare time. I was learning Java and wanting to put my newly learned knowledge to use to further cement it all in my mind. I chose to make this program because it used so many different aspects of the code. Writing to flat files, networking, GUI among other things.

I originally wrote a similar program in college using VB6(yes VB6 lol) but this senior project used an encryption algorithm. When the user logged into the server the password was encrypted, sent to the server where the encrypted passwords were compared. Then the clients messages were encrypted before being sent to the server. The other clients would decrypt the message and display it.

What I had issues with while coding

One of the biggest struggles was with lining up the message correctly. The format looked like this

client

After much trial and error I realized it was the font I was using. I ended up going with a mono spaced font.

Another issue where I was overthinking the way data gets moved was with the list of users. In my mind initially I thought that only the new username had to be sent to all clients that are connected. This is true for everyone except for the new user that just logged in. I ended up keeping a list of all users and sending that updated list every time someone logged in.

sep

To see more screen shots and download the source code go to my site here. This was written years ago so some of it may be out of date, but I hope it's still useful to some.

Check out my other Recent Posts!
Crossfit Open 18.1 results
ESRI REST Services with C#