Project Description - Soulyyy/chat-service GitHub Wiki

This is a simple chat project built on REST.

The project Uses:

  • JDK 1.8
  • Gradle
  • Jersey for the REST provider
  • SLF4J for logging
  • Lombok for more readable broilerplate code
  • Jackson for JSON parsing

The currently consists of 4 modules:

  • Client (fat jar)
  • Server (war)
  • Commons
  • Backend

The Client handles communication with the Server. It has one command line parameter, which is the address of the server one wants to connect to. The Client first asks the user for a username and sends it to the Server. The Server sends a message to all other connected clients through a ServerSentEvent notifying that a user with the given name has connected. The Server also asks the Backend for history of messages sent before the Client connected which are then returned to the Client. Then the client also connects to the SSE broadcaster, receiving all broadcasted messages. Now, whenever the user types a message and hits enter, it will be broadcasted to all listeners. This is like a notification pattern, but the keepalive signals are handled by the SSE implementation.

The Client is only aware of the REST endpoints the Server provides and has to request resources by itself. So, generally, the notion of SSE defies the core principle of Web Services, that they never respond by themselves.