In this chapter, we will show our system implementation by the architecture and function.2.1 Client
A textbox is designed on the top of the screen to make judgement of user enter single chat room or broadcast and we also design a message textbox on the bottom of the screen to provide user type message.
A single chat function is used to send and receive a message to the specific user and broadcast is used to send and receive message to all users. A user can enter single chat room or broadcast after create a userID. If userID is typed into textbox and it can be found in the server, user will enter into single chat room automatically. On the other hand, if any userID cannot be found in the textbox or server, user will enter into broadcast automatically.2.2 Server
Our server focuses on delivering messages from clients. Dependent on sender and receiver (id and to), the server will have different reaction. For example, if receiver is empty, the message will be send to all terminal connected to the server. As a simple chat application, we select to use a stream connection between server and client instead of building up both client and server on each terminal.
Since time is limited and we prefer to accomplish existing components like UI and server function, we did not set up a database for our server. Instead, we simply create a map and a set to store features of clients.
Because of our server does not know the IP address. To solve this problem, we design a start page to let a user create a userID, once the user clicks the create button, a userID and the IP address will be sent to the server. A userID and IP address will become a key and value stored in a map or set.2.3 Message Display
In order to classify the send messages and received message. We use Boolean to distinguish the message is sent or received. Then, we draw the chat bubble by using XML to display the message. A chat bubble is designed with two different colors. In addition, sent message and received message is designed to display in two different sides.
We create a java class to make chat bubble for any sent and receiver message. When it called by the sent message, it will return an orange chat bubble and show the message on the right hand side. Otherwise, it will return an blue chat bubble and show the message on the left hand side.