Chris Pollett >
Students > [Bio] [Blog] |
Deliverable 3 - Feature Addition: MailSiteDescription: Another command feature that can be added to The HELP Command
Step-1: Creating a JSON list of all commands and their descriptions:
Sample JSON :
Step-2: Implementing the main functionThis function serves to read the JSON file generated previously, decoding its contents into a printable string format. Subsequently, it incorporates all key-value pairs into this parsed string and proceeds to return it. Furthermore, the function diligently manages any file-related errors that may arise during its execution. parseHelp()
returns the response string created with the response code added. 214- Available commands:
+
<---commands--->
+
214 End of HELP response
Step-3: Integration into parseRequestThe integration process entails merging the aforementioned function into the parseRequest function, complemented by meticulous checks to ensure seamless operation. Subsequently, the response generated by the function is appended to the 'out_stream', facilitating its transmission back to the client for further processing. Step-4: Integration into ProcessRequestStreamsThe process involves updating the processRequestStreams function, incorporating pertinent checks to accommodate the newly introduced command effectively. Additionally, the resultant data stream, encapsulated within the 'out_stream', is then forwarded back to the client, thereby completing the request-response cycle. Example Code:
ResultsFind the full code below:MailSite Github Project |