Task 6 writing the client 3 marks by now you should

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: can be tested from telnet; i.e. don’t make it difficult to actually type your commands! You will need to show your design when you get your work marked. It should include a list of the commands, and what they do. You should also write pseudo code that describes how your server will handle the various commands, and in what order etc (you can draw an informal flowchart for this if you prefer). Task 5 : Implement your protocol [4 marks] Now you should implement your protocol; most of the work will take place in your ‘onMessage’ method, though you may find that you want to use the ‘onConnect’ method too for initialising user ­specific data (and perhaps even the ‘onStart’ method for initialising server ­wide variables). You have already seen (or written) enough code in this lab exercise to have covered all the important bits of functionality you need, e.g. decoding a message, sending a message back over a socket to a client etc. One important point to note at this stage. Remember that unlike in Java, Python allows you to create variables on the fly (and is happy as long as you’ve assigned some value to a variable before you try to read from it). This also applies to member variables – which may seem a little odd – but is quite useful for short programs like this. What this means is that if you want to add new attributes to a ‘user’, you can hang them off the socket information that gets passed to you via onConnect and onMessage. So for example, in onConnect you might do something like def onConnect(self, socket): # Initialise connection-specific variables socket.screenName = None and then later in onMessage, somethin...
View Full Document

This document was uploaded on 02/10/2014.

Ask a homework question - tutors are online