Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 python3 a5.py 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 5, 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 1: 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 ds_protocol 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":"user_token", "directmessage": {"entry": "Hello World!","recipient":"ohhimark", "timestamp": "1603167689.3928561"}}
# Request unread messages from the DS server
{"token":"user_token", "directmessage": "new"}
# Request all messages from the DS server
{"token":"user_token", "directmessage": "all"}
Recall from a3 that user_token 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 1!", "from":"markb", "timestamp":"1603167689.3928561"},{"message":"Bzzzzz", "from":"thebeemoviescript" "timestamp":"1603167689.3928561"}]}}
To process these new response messages, you will need to extend the message conversion code that you wrote for a3. How you solve this requirement is up to you, but a good approach will likely include adding a function to your ds_protocol 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 (e.g., import ds_protocol, if you are extending your ds_protocol 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_:
test_ds_message_protocol.py
Once your test program is complete, you can move on to the next part of the assignment.
Part 2: 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 ds_messenger.py
It must implement the following classes and methods
class DirectMessage:
def __init__(self):
self.recipient = None
self.message = None
self.timestamp = None
class DirectMessenger:
def __init__(self, dsuserver=None, username=None, password=None):
self.token = None
def send(self, message:str, recipient:str)-> bool:
# must return true if message successfully sent, false if send failed.
pass
def retrieve_new(self)-> list:
# must return a list of DirectMessage objects containing all new messages
pass
def retrieve_all(self)-> 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 ds_messenger.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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learn To Program Databases With Visual Basic 6

Authors: John Smiley

1st Edition

1902745035, 978-1902745039

More Books

Students also viewed these Databases questions

Question

LO14.1 Describe the characteristics of oligopoly.

Answered: 1 week ago