Chat App
Basic Features
Write a check before writing the function! Beginning with step 3.
-
Read requirements and decide on a model.
-
Set up the model with updater functions like
update-co: player new-co -> player
. -
Write a draw handler to display a list of messages.
-
Write a key handler so you can type a message and then send it.
- Backspace deletes letters. (CHECK EXPECT!)
- Keys like “shift” and “control” with more than one letter in their names are ignored. (CHECK!)
- Enter sends the message. (CHECK!)
Advanced Features
-
Chat-style layout, where your own messages appear on the right and others on the left.
-
Scrollback using up and down arrows.
Suggestion: Add a number field to the player structure - how many lines to skip before showing any.
-
Muting a sender. Keep a list of senders to ignore. Add to it my sending a message command like:
/mute docmo
Note: this does not have to be sent to other worlds. Think how you would do this before coding!
Demonstration and Walkthroughs
If you are confident, you do not want to begin with all of this code. Writing your own is better! Do use the same chat message format so that you can interact with other peoples’ applications.
<div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
<iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="allowfullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/5EZYk3EFzx8?autoplay=0&controls=1&end=0&loop=0&mute=0&start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="A demonstration of the chat app with three communicating windows."
></iframe>
</div>
There are walkthrough videos accessible to CPS students. See the “Chat App” series in the Resources tab of the Assignment Calendar.