Archive‎ > ‎Fall 2009‎ > ‎Course Project‎ > ‎Buddy Suite‎ > ‎

Milestone 5: Smart Chat (Optional)

Please mind the Collaboration Policy. If you have any questions regarding the assignment, do ask the course staff

The total number of points for this milestone is 100.
The points are awarded as follows:

  • Functional ant build file. If the build fails, the milestone will not be tested further - 5 points 
  • Implementing a functional chat protocol - 15 points
  • Being able to start a chess game while chatting - 5 points
  • Handling multiple chat sessions - 5 points
  • Implementing automatic chat message translation - 15 points
  • Implementing a functional chat log search engine - 15 points
  • Implementing chat log loading from file - 5 points
  • Implementing chat log erasing - 5 points
  • Profiling the search method - 10 points
  • Implementing a fast search engine - 20 points

1. Overview

For this milestone you will implement a Smart Chat that will allow buddies to communicate with each other. The cool feature of this chat will be the ability to chat with any buddy, in any language. Your Smart Chat will do this by automatically detecting the language used by each buddy and automatically translating incoming messages in their language. This way, an English speaking buddy and a French speaking buddy will be able to chat without speaking each other's language. 

To start a Smart Chat conversation, users can click on their buddies and choose the option to chat. Moreover, during a chess game, buddies should also be able to start a conversation with the chess buddy, or initiate a new conversation with a new buddy. An example interface is in the figure below. 

SmartChat should allow the user to have multiple chat sessions open in parallel. Moreover, the user should be able to start a chat session either by selecting a friend in the FriendFinder View, or by choosing the chat option while playing a chess game. 

2. Chat Protocol

Chat messages go through the same server used so far. The format of a chat message is specified in the client-server protocol specification. Here is the excerpt relevant to chat messages:

To send a message: 

  <chat username=".."><msg>..</msg></chat>

Possible replies from the server:

  • <chat username=".."><ack ></ack></chat>
  • <chat username=".."><nack msg=".." ></nack></chat>


For Alice to send a message to Bob, she needs to send the following command:

  <chat username="Bob"><msg>Why do we always get used for examples?</msg></chat>

If the server replies with ACK to Alice, Bob will receive:

  <chat username="Alice"><msg>Why do we always get used for examples?</msg></chat>

3. Translate

The requirement for translation is that SmartChat figures out automatically the language the user is writing in. The user does not have to configure any language preferences. All incoming chat messages will be translated in the language of the user. For instance, if Alice is writing in English and Bob is writing in French, all messages from Alice to Bob will be translated by Bob's BuddySuite from English to French. 

For translation you should use the Google Translate Java API.

4. Chat Log Search

You have to provide a search function that allows users to search through previous chat messages. The chat log has to be persistent across reboots of the BuddySuite application and of the phone. The log is likely to be large and not fit in main memory, therefore you must store it on the phone's persistent memory or on the sdcard. 

To create an sdcard image to be used with the emulator, you can run a command similar to:
    mksdcard 100MB <path_to_sdcard>/card

To start the emulator with an sdcard, you can run a command similar to:
    emulator -avd androidbeatsiphone -sdcard <path_to_sdcard>/card

You are allowed to store the chat log in any format you like and use any functionality provided by the Android SDK to perform the search. 

Users should be able to load a plain text file into the chat log. For this, you need to provide a way to input the name of a file on the sdcard and a button to load it into the chat log. Each line of the plain text file loaded should be added to your internal chat log representation. This functionality is worth 5 points.

For privacy reasons, users should be able to clear the chat log (i.e., erase the entire content of the chat log and create a new empty log). For this, you will receive 5 points.

  •     The results of the chat log search will be displayed in the conversation window, with a prefix that differentiates them from the other chat messages. 
  •     Display a maximum of 10 results for each search
  •     The search is not case sensitive.  
For instance, for the following chat log:
    Alice: this is a real chat log
    Bob: no it is not
    Alice: yes it is

Searching for:
  • iS will return all chat messages
  • YE will return the third line
  • s No will return the third line
  • chatlog will not return anything

5. Performance Profiling

You have to profile your application to see any performance bottlenecks. For performance profiling you will use TraceView. Follow the instructions in the TraceView tutorial to see how to collect performance statistics and how to display them. To enable profiling the entire application, place the call to startMethodTracing() in your activity's onCreate() method, and call stopMethodTracing() in that activity's onDestroy() method.

Your goal is to profile the search functionality and see what percent of the entire execution time is occupied by the search. The format you store the chat messages will likely influence the performance of the search. To profile the performance of your search, you will search through this test file, made out of some of the Linux source code files, for the string "epfl".

Your milestone documentation should contain a snapshot similar to this one. Write down in your README file the number of inclusive cycles and the percentage for the top search method. Also include the profile trace, so that the TAs will be able to view it in TraceView.  You will receive 15 points for implementing the search functionality, and 20 more points if the search method is faster than 2600 inclusive time while searching for the string "epfl" in the test file (the inclusive time is shown in the third column in TraceView). 

6. Deliverables

Please send an email to the SwEng Staff with the link to the SVN repository where your project is located. Remember, the structure of the folder defined by the address you provide must pass the check_structure.bat test. The link to your SVN repository should be sent by December  7th, the latest.

By December 8th, you have to hand in:
  • The code for all deliverables: FriendFinder + ChessGameUI + ChessGame Logic + ChessGame Net + SmartChat
  • A documentation directory that contains the TraceView snapshot, the profiling trace and a README file that contains the numbers for the inclusive cycles and the percentage of the top search method. 
  • ant build file that:
    • compiles the code
    • creates the apk file
    • installs the application on the two running emulators, corresponding to two friends
    • runs the provided test suite plus the test you developed

    A functionally complete build file will be rewarded with 5 points. If your build file does not do all of the required actions, you will get 0 points. Furthermore, your project will not be evaluated.

  • Note: The code you deliver must run on the client's machine. A client is not going to be happy if the developers tell him/her that the program worked on the developers' machines. The computers in the BC07-08 laboratory are the client's machines. Your code must run on the BC machines.
  • You must use the script check_structure.bat on the BC machines to check that your build system complies with the requirements. Download the attached check_structure.ba_ and rename it to check_structure.bat. Run it by invokingc:\path_to_check_structure\check_structure.bat path_to_project, for example using check_structure.bat "c:\Documents and Settings\myname\sweng"

7. FAQ

    Q: Is the language detection supposed to be automatic?
    A: Yes, the chat should infer the language automatically based on the messages typed already by a user. Sometimes you may not auto-detect with high accuracy, but you can pick the best guess. You should not ask the user about the language or look into the local properties.

   Q: How can one get the points for milestone 5?
   A: - milestone 5 has 100 points
       - milestone 5 weighs as much as the other milestones
       - you can only get the points for milestone 5 if your score for milestone 4 is above 95