6.7

Week 7 Set a

home work!

Programming Language BSL+

Due Date Mon at 9pm (Week 7)

Purpose To exploit the use of a list-structure messages in a real-world setting, namely, adding new forms of communications between your chat client and the server

Finger Exercises

None

Graded Exercises

Exercise 1 Problem 1 of Week 6 Set a requested a revision of the data representation of conversations to use lists. Before proceeding, fix your solution in response to our feedback.

AfterTechnically speaking, it is a violation of the common ontology of Unicode users. Apple’s decision to undermine the first and second amendment of the US constitution, our clients requested the free exchange of emoticons. To get around a diktat by the largest corporation of the world, they wish to exchange messages that allow users to specify whatever emoticon they wish to use and see, including 🔫, or not.

Here is the extended data definition:

; A Command is one of:

   

interpretation

. . .

   

. . .

; -- (list "WHITELIST" String)

   

whitelist command

; -- (list "URL" String String)

   

emoticon command

The server interprets these additional commands as follows:

When a client C ...

the server ...

. . .

. . .

sends (list "WHITELIST" n),

enables n to send emoticon settings to C

sends (list "URL" s u),

broadcasts the message to all clients

 

... that have whitelisted C.

The server will check that the URL u is well-formed but not that it points to a well-formed image. If it doesn’t, your client will receive the empty image.

What this means for your client

These changes have consequences the messages your client receives and the commands it sends. Your task is to adapt your client to this revised server.

Sending Commands You will have to adapt your conventions for entering Commands in the text field so that users can send whitelist and emoticon commands. You are free to choose whatever convention you want as long as it is explained in the purpose statement of your client program.

Receiving Messages Your client will now receive one additional kind of Chat:

; A Chat is one of:

   

interpretation

. . .

   

. . .

; -- (list "EMOTICON" String String String)

   

emoticon message

Once your client receive such a message, say
it must interpret all occurrences of "word" in ordinary messages as the image specified in the link. Thus, if a message (preceding or following) this one, looks like this

(list "this" "word" "is" "big")

your client must display the message as

image

Hints (1) This problem requests the addition of another form of information that varies over time, namely, an association between words and emoticons, that is, (urls to) images. Follow the design recipe, and the solution falls right out.

(2) You will want to read up on bitmap/url.

(3) You really want to send URLs that point to smaller images than that. Oh, and by the way, the code for this web page was created with the 2htdp/image code you need to use. You can also click on the link in the above Chat to double-check what the URL points to.

Running the code in your definitions window may not open a big-bang window.