Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a simple LAN messenger

I want to create a simple LAN conference-chat style messenger in Java but I have no clue where to start.
It must have the following features:

  • no permanent username: the user must be able to type in a username every time he joins but should have a remember me option in case he uses it frequently
  • a simple chatroom interface with all the users online displayed on the right and the chat messages in the centre
  • a private chat service and a block option
  • I do not want the ready-made code, I want someone to explain to me where to start and how to go about doing it and the things I should know (like e.g. a text box to enter user name and stuff )
    Just imagine it as being a messenger allowing all the employees in one building to chat with each other
    like image 618
    A User Avatar asked Dec 09 '22 23:12

    A User


    1 Answers

    Though your question is pretty vague you seem to have the basics (sockets and all that) in place. I suggest you start by reading the All About Sockets and All About Datagrams Java lessons on Oracle's site to get started. The main content from the second lesson you may want to digest is the part about broadcasting (for the purposes of automatic server detection).

    Here's how i'd go about the implementation on a high level:

    • Implement an application that contains server AND client functionality in one executable.
    • When the app is started, run the server if no other server is detected (automatically or specified by the user).
    • Always run the client. What this means, is that no dedicated server will be used as one of the clients acts as the server. Each client connects to the server (including the client running on the same machine as the server).

    There obviously are numerous ways to make this kind of an application. I'm not saying that the way that i described is the best. It is, however, probably suitable to the use case you described, and its implementation is fairly simple.

    like image 84
    Kallja Avatar answered Dec 29 '22 00:12

    Kallja