SSE554Project3-IMApp

=Instant Messenger = =4.2. David's Application=  4.2.1. After I got David’s code and implemented it I had several difficulties. Not due to his code, but to the nature of the program. Connecting computers with IP address is not something to be taken lightly. In my initial attempts I was receiving data but could not send. Hence, this is one of the reasons for choosing this type of project to do; for its complexity.



 4.2.2. After some adjusting of the IP addresses I was able to send messages back and forth.



 4.2.3. After I got the program working I made some visual modifications to show that I was using two different computers and had a conversation with myself. **Update:** After talking with David and analyzing his code the decrypt method was available. So I re-ran the application and included the screen shots.



 4.2.4. So how was this program created? Here is the implementation of the program and what is under the hood. It starts out by creating a thread for the Listen method and starts it in the background. Then it sets the title of the program with the computer name so you can tell which chat window is what.



 4.2.5. The Listen method is attached to port 2112 and listens for incoming traffic. The use of threads is important because if this method was part of the main program the program would be in a wait state and not allow you to do any other operation. The thread allows you to do other operations. The method stops when you start the listener. It will pause until traffic is received. Once there is a message at the port the method attempts to receive the message. It reads the TCP stream and then converts it to a stream reader. In the stream reader form the stream is read to the end and converted to a string and displayed in the conversation box. **Update:** This is where you creat an encryption object and pass the results of the recieved data and give it a decrypt option.


 * Updated Version**

4.2.6. The next part of the program is the delegate. When the listener receives the message it triggers the update delegate so it can update the conversation text box.



 4.2.7. The final part of the program is the send method. The method takes the text of the message and formats it for display. It then attempts to make a TCP connection using the destination computers IP address. Once the connection is made it takes the message string and encrypts it (using the encryption class) and sends it over the TCP stream. If there is a problem it will update the conversation box with the error.



 4.2.8. The encrypt class accepts a string and converts it to a character array. Then it gets a key from the registry and applies a bit shift of the character in the character array. Then it adds it to the message holder. Once the message is compete it returns the converted text.



 4.2.9. The getRegistryKey access the key value from the registry. If it doesn’t exist it creates the key.



 4.2.10. Here is the key that was entered in the registry.



 4.2.11. That completes David’s Instant Messenger program.

Project Home Next Section