ucsb-cs56-projects / cs56-networking-chat

-
1 stars 6 forks source link

Refactor the Server service codes used by the system and make them all consistent. #51

Open jleeong opened 7 years ago

jleeong commented 7 years ago

Currently the structure of the service codes in use is inconsistent. It maintains a loose structure of

[message]&[arg0]:[arg1]:...

but this is not completely formalized and it is unclear how service codes are used. Because the server and the client would theoretically be on different machines the structure of the messages sent between them and the service codes included are the only way for the server and client to synchronize their states (who is online, what chatrooms exist).

The Observer pattern cannot be deployed here because a Client and a Server object have no knowledge of the other. It is suggested that serious effort be put into developing a rigorous protocol for messages sent between server and client, documenting the protocol in a clear and consistent manner, and fixing the implementation of the Client and Server code to adhere to the messaging protocol.

Example

One suggestion for a possible protocol to implement is to structure the messages in the following way:

[message]&[service-code]:[arg1]:[arg2]:...

Here [service-code] will take some integer value (e.g. 1001, 1002,...) and each service code will have corresponding argument fields. For example one such service code formulation may be like this:

service-code [1001] Description: Normal instant message originating from User1, intended for delivery to User2 Arguments: String nicknameU1, String nicknameU2 example formulation: this is a test message&1001:jgaucho:cs56student

Point Estimation

Because the code in its current condition is so reliant on the current, inconsistent protocol, this refactoring will take significant time and effort to fix.

Recommended points: 500

seemantasaha commented 6 years ago

W18 OK. 500 points.