Question: Important: when running your assignment as python 3 a 5 . py the GUI should load automatically. In your final project, you will build upon
Important: when running your assignment as python apy the GUI should load automatically.
In your final project, you will build upon and extend what you have learned in the course and what you completed in your assignments. In assignment you will integrate multiple aspects of what you have learned in the class to create a complete software product!
For your final assignment, you will develop a module that enables a program to send and receive direct messages to another user on the DSP platform. You will then incorporate this module into a graphical user interface GUI using Tkinter that should allow any student to communicate with any other student in this class as long as they know each other usernames.
To help you get started, the requirements for your final program have been divided into different parts. You are encouraged to follow each part in order. Note that each part can be written and tested independently.
Very important: do not wait until near the deadline to start this project, as you will certainly not have time to complete it if you do so and this project deadline will not be extended.
Part : Implement the Direct Messaging Protocol
To communicate with another user on the DSP platform, your program will need to use new protocol messages. To support these new messages, your program must extend your dsprotocol module to support direct messaging with the following commands:
directmessage
Accepts a message to be sent directly to another user. The username is passed in the "recipient" part of the command. Also retrieve messages from the server. Example:
# Send a directmessage to another DS user in the example bellow, ohhimark
token:"usertoken", "directmessage": entry: "Hello World!","recipient":"ohhimark", "timestamp":
# Request unread messages from the DS server
token:"usertoken", "directmessage": "new"
# Request all messages from the DS server
token:"usertoken", "directmessage": "all"
Recall from a that usertoken is retrieved by sending a successful join command. So to send a direct message, you must first join the server and retrieve the token that you must later use.
The DS server will respond to directmessage requests with the following ok response messages:
# Sending of direct message was successful
response: type: ok "message": "Direct message sent"
# Response to request for all and new messages. Timestamp is time in seconds
# of when the message was originally sent.
response: type: ok "messages": message:"Hello User "from":"markb", "timestamp":"message:Bzzzzz "from":"thebeemoviescript" "timestamp":"
To process these new response messages, you will need to extend the message conversion code that you wrote for a How you solve this requirement is up to you, but a good approach will likely include adding a function to your dsprotocol that converts JSON messages to a list or a dictionary.
Writing a Test
When your code is complete, write a small test program to verify that your messages are processed as expected. Your program should import your module eg import dsprotocol, if you are extending your dsprotocol module and call the code you have written with a few test messages. You can use the messages provided as examples above or create a few of your own as test cases. You can name your test whatever you like, but it should be prepended with the word test:
testdsmessageprotocol.py
Once your test program is complete, you can move on to the next part of the assignment.
Part : The DS Direct Messenger Module
Now that you have a functioning protocol, you can write your message send and retrieve code. The first thing you will do is complete the direct messenger module. Your module must adhere to the following rules:
It must be named dsmessenger.py
It must implement the following classes and methods
class DirectMessage:
def initself:
self.recipient None
self.message None
self.timestamp None
class DirectMessenger:
def initself dsuserverNone, usernameNone, passwordNone:
self.token None
def sendself message:str recipient:str bool:
# must return true if message successfully sent, false if send failed.
pass
def retrievenewself list:
# must return a list of DirectMessage objects containing all new messages
pass
def retrieveallself list:
# must return a list of DirectMessage objects containing all messages
pass
You are free to add as many supporting methods to either of these classes as you need, but the dsmessenger.py module must be able to function without any other dependencies. A program that imports your module should be able to call the required functions to exchange messages with the DS server. You may reuse or import the code
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
