• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

I need help improving this chat server and chat client!

 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
Cody Long
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you for your help i figured out how to do it in time.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Cody Long
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yeah but thankfully newbishness seems to come off pretty quick sometimes!
 
reply
    Bookmark Topic Watch Topic
  • New Topic