| Author |
I need help improving this chat server and chat client!
|
Cody Long
Ranch Hand
Joined: Jan 01, 2009
Posts: 95
|
|
Can someone please help me make this server more secure and the chat client looking a little cooler. Also can you show me how to make it where a user types in their names and it shows up next to the text that they sent? right now it just shows what a person wrote, not wich person. thank you.
ChatServer.Java
ChatClient.java
|
Duct tape is like the Force. It has a dark side, a light side, and it binds the whole universe together.
|
 |
Rob Spoor
Saloon Keeper
Joined: Oct 27, 2005
Posts: 18365
|
|
The server has to inform the clients on who has sent the message. You can do that by either sending the user name from the client with the message, or by recognizing the user from the specific ClientHandler. I'd say the first solution is the easiest, and it keeps user names local to one place.
As for security, you could add both a welcome message and a departure message. A client first sends the welcome message when connected, and the server rejects the socket if the welcome message does not match. If a client disconnects it can send a departure message that allows your server to nicely clean up its resources (and inform other users that the user has left).
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Cody Long
Ranch Hand
Joined: Jan 01, 2009
Posts: 95
|
|
Rob Prime wrote:The server has to inform the clients on who has sent the message. You can do that by either sending the user name from the client with the message, or by recognizing the user from the specific ClientHandler. I'd say the first solution is the easiest, and it keeps user names local to one place.
As for security, you could add both a welcome message and a departure message. A client first sends the welcome message when connected, and the server rejects the socket if the welcome message does not match. If a client disconnects it can send a departure message that allows your server to nicely clean up its resources (and inform other users that the user has left).
how would you do that? i am a beginning programmer and got the server code from a friend and i dont know where he got it. the client part i made via the server info but i still can not figure out how to get the username [art and how to add more security.
|
 |
Cody Long
Ranch Hand
Joined: Jan 01, 2009
Posts: 95
|
|
thank you for your help i figured out how to do it in time.
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 14606
|
|
Cody Long wrote:thank you for your help i figured out how to do it in time. 
Well, I am sure that once you figure out the code, then Rob suggestions will start to make sense. It is hard to change code when you don't know how it works -- especially for a beginner.
Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
Cody Long
Ranch Hand
Joined: Jan 01, 2009
Posts: 95
|
|
|
yeah but thankfully newbishness seems to come off pretty quick sometimes!
|
 |
 |
|
|
subject: I need help improving this chat server and chat client!
|
|
|