Messaging¶
The PV080 server (https://pv080.fi.muni.cz/) provides a functionality to
exchange messages between students. The type
of the content of the message
is bytes
. To send a message to a particular UČO use the function
send_message
and to receive a
message use the recv_message
function.
Each message comes from a sender UČO and is sent to another UČO (the sender and the receiver can be the same person). For every pair of UČO only the last message is recorded.
- pv080_crypto.messaging.send_message(uco_from: int, uco_to: int, content: bytes) str [source]¶
Sends the
content
to https://pv080.fi.muni.cz/msg server, where it is readable by anyone on the internet.- Parameters:
uco_from – Is the UČO of the sender.
uco_to – Is the UČO of the receiver.
content – Is the message encoded in bytes.
- Returns:
The status message of the result of this API call to the server.
Example:
>>> send_message(uco_from=408788, uco_to=408788, content=b"message") 'overwritten'
- pv080_crypto.messaging.recv_message(uco: int) Mapping[str, int | bytes] [source]¶
Receive the messages that have been sent to
uco
.- Parameters:
uco – Is the UČO of the addressee/receiver.
- Returns:
A dictionary where the keys are UČOs of the senders and values are their messages.
Example:
>>> send_message(uco_from=408788, uco_to=408788, content=b"message") 'overwritten' >>> messages = recv_message(uco=408788) >>> message_from_408788 = messages[408788] >>> assert message_from_408788 == b"message"