mardi 3 janvier 2023

How to make low level design especially Class Diagram

I am stuck how to think or proceed to make class diagram as i am making a chat application using TCP socket programming using NodeJs.

I made the High level design of this application in form of Use Cases. I just need how to make low level design especially class diagram from this use cases. ANY HELP WOUL BE APPRICIATED.

Usecase1-

o   User starts the client program. Client connects with the server. & Now client is asking user to enter his/her name.
o   User will Enter his/her name “xyz”, and take this text input and convert it into JSON and Send it to the Server.
o   Now Server will receive this data from client and convert it into JSON Object. And it will store its username to its database i.e. HashMap. And display “new client connected” to server console.
o   And moreover Server will make an array of all username presents in map (if there are username present into map), convert this to JSON and send back to client who initiated the cmd.
o   And Client will receive the data, convert back to JSON Object (along with that it stores in an array) and display it to the user, from where user can select the username he/she wants to chat

Usecase1.1-

o   If any new user is connected/exit from the server, (following usecase1).
-   As soon as it connects, we send String “username join the chat” to each connected client that are connected to server except client which just connected.
-   We have a function which reads command prompt input, and as user typed “exit”, client send “username left the chat” to each connected client and request to end its connection to server. 


Usecase2-

o   User will Enter, username whom he/she wants to chat. Client take the input and check that username present in the client array or not. If username is not present in the array, then simply display “Enter valid user”.
o   If username is present in the array, Client ask user to “Enter message”.


Usecase3 –
    
Now user1 will enter message he/she wants to send to user2.
Client take the input and convert it into JSON having attributes, cmd: Send, Sendby:user1, Sendto:user2, message: “message”. And send it to the server.
Where server receives the data, convert it into JSON Object and look for attribute cmd i.e. Send, and look for the sendto user i.e. user2 in hashmap (i.e. user still connected with the server) and if user2 connected with the server then simply send this data to Sendto user i.e. user2 in JSON format & return msg: “success” to sender user (user1), else return msg “User disconnected”, in JSON format having attributes cmd: “server reply” & msg: User disconnected” to sender user i.e. user1. 
Now user2 receives the data, convert it into JSON Object, and look for attribute message and sendby, and Simply display the message to user2.And send msg: “received” to server.


Usecase4 –
If any user wants to end the connection. Simply enter ‘quit’ in, client send this data as command to server in JSON, server check the cmd attributes and disconnect along with remove that user name from array & hashmap, & send this message “username left the chat” to every connected client.

Aucun commentaire:

Enregistrer un commentaire