Difference between revisions of "DT 8025 2016 Practical 3"

From CERES
Jump to: navigation, search
Line 30: Line 30:
 
=== Overview ===
 
=== Overview ===
  
The goal of this project is to implement a simple Android app for the Rock Paper Scissors online game.
+
The goal of this project is to implement a simple Android app for a Rock Paper Scissors online game.
The only part of functionality that we adopt in our practical is to:
+
The functionalities that we adopt in our practical is to:
  
 
* Connect to an [[media:RPSServer.zip|RPS server]],
 
* Connect to an [[media:RPSServer.zip|RPS server]],
Line 43: Line 43:
 
* Accept/reject a play request from another player,
 
* Accept/reject a play request from another player,
  
* Fetch the list of play requests owned by the current player,
+
* Fetch the list of play requests either from or to the current player,
 
+
* Fetch the list of play requests with the current player,
+
  
 
* Make a choice (Rock/Paper/Scissors) and fetch the choice of the other player
 
* Make a choice (Rock/Paper/Scissors) and fetch the choice of the other player
Line 71: Line 69:
 
Then, the app will provide three possible options:
 
Then, the app will provide three possible options:
  
* view online players to send play request to,   
+
* view online players (to send play request to),   
  
* view pending play requests to answer by the player, and
+
* view pending play requests to be answered, and
  
 
* view sent play requests (waiting/accepted/rejected).
 
* view sent play requests (waiting/accepted/rejected).
 +
  
 
=== View Online Players  ===
 
=== View Online Players  ===
  
The app shows a layout in which the list of online players and their status (idle/busy/waiting) is shown and the user can select one of the idle players to send a play request to.
+
The app shows a layout in which the list of online players and their status (idle/busy/waiting) is shown. To fetch the list of online players the client send the following request
 +
 
 +
<OnlinePlayers/>
 +
 
 +
Then, the user can select one of the idle players to send a play request to.
 +
 
 +
=== Send Play Request ===
 
When the user select the player (in any way) the client sends the following structure to the server
 
When the user select the player (in any way) the client sends the following structure to the server
  
 
  <PlayRequest Mahsa/>
 
  <PlayRequest Mahsa/>
  
The serve will reply to the meeting scheduler
+
The serve will reply to the request
  
 
  <Play request was sent to Mahsa!/>
 
  <Play request was sent to Mahsa!/>
Line 92: Line 97:
 
=== View Pending Play Request  ===
 
=== View Pending Play Request  ===
  
The user may ask whether there has been any play request in which the current user is mentioned as the participant.  
+
The user may ask whether there has been any play request to be answered.  
 
In this case, after this option is selected from the main menu, the client  
 
In this case, after this option is selected from the main menu, the client  
 
send the following command  
 
send the following command  
Line 102: Line 107:
 
  <PlayRequest From="Masoumeh" With="Mahsa" status="waiting"/>
 
  <PlayRequest From="Masoumeh" With="Mahsa" status="waiting"/>
  
The participant fetches one of the requests for the participant and then to accept the request sends
+
=== Accept Play Request ===
 +
The user may select one of the requests to her/him and accept/reject the request.
 
 
 
   <AcceptPlayRequest Masoumeh/>  
 
   <AcceptPlayRequest Masoumeh/>  
  
and to reject it sends
+
or
  
 
   <RejectPlayRequest Masoumeh/>  
 
   <RejectPlayRequest Masoumeh/>  
  
The server will then update the status of the correspondent request to 'accepted' and 'rejected' respectively, and send back  
+
The server will then update the status of the request to 'accepted' and 'rejected' respectively, and send back  
  
 
  <PlayRequest From="Masoumeh" With="Mahsa" status="accepted/rejected"/>
 
  <PlayRequest From="Masoumeh" With="Mahsa" status="accepted/rejected"/>
Line 116: Line 122:
 
=== View Sent Play Request  ===
 
=== View Sent Play Request  ===
  
The user may ask whether there has been any play request in which the current user is mentioned as the participant.  
+
The user may ask for the play request sent by him/her.  
 
In this case, after this option is selected from the main menu, the client  
 
In this case, after this option is selected from the main menu, the client  
 
send the following command  
 
send the following command  
  
   <PlayRequestsForMe/>
+
   <MyPlayRequests/>
  
The server send all pending requests for the participant one by one like  
+
The server send all requests from him/her one by one like  
  
 
  <PlayRequest From="Masoumeh" With="Mahsa" status="waiting"/>
 
  <PlayRequest From="Masoumeh" With="Mahsa" status="waiting"/>
  
The participant fetches one of the requests for the participant and then to accept the request sends
+
=== Discard Play Request ===
 +
The user may decide to discard one of his/her request by select on the requests and send the following command
 
 
   <AcceptPlayRequest Masoumeh/>
+
   <DiscardPlayRequest Mahsa/>  
 
+
and to reject it sends
+
 
+
  <RejectPlayRequest Masoumeh/>
+
 
+
The server will then update the status of the correspondent request to 'accepted' and 'rejected' respectively, and send back
+
 
+
<PlayRequest From="Masoumeh" With="Mahsa" status="accepted/rejected"/>
+
 
+
=== Creating a new request ===
+
 
+
The app shows a layout in which the user can enter a unique meeting Id, a number of time-slots (for simplicity we assume that all meetings take one hour and hence, it suffices to mention the starting time), and identifiers of three participants.
+
When the user presses the submit button,
+
the client sends the following structure to the server
+
 
+
<OpenMeeting>
+
    <MeetingId "5"/>
+
    <Message text = "Please select a time for the coming meeting."/>
+
        <time = "8:00"/>
+
        <time = "10:00"/>
+
        <time = "9:00"/>
+
    <Participant numberOfParticipant ="3">
+
        <name = "clientParticipantA"/>
+
        <name = "clientParticipantB"/>
+
        <name = "clientParticipantC"/>
+
      </Participant>
+
<OpenMeeting/>
+
 
+
The serve will reply to the meeting scheduler
+
 
+
<Request to start meeting is accepted/>
+
 
+
This is shown by a toast message and the app will return to the main menu.
+
 
+
=== Checking for open requests ===
+
 
+
The user may ask whether there has been any meeting request in which the current user is mentioned as a participant.
+
In this case, after this option is selected from the main menu, the client
+
end open meeting request like
+
 
+
  <CheckOpenMeeting/>
+
 
+
The server send all open meetings for the participant one by one like
+
 
+
<OpenMeeting>
+
      <For "+clientParticipant+"/>
+
      <MeetingId "5"/>
+
      <Message text = "Please select a time for the coming meeting."/>
+
      <time = "8:00"/>
+
      <time = "10:00"/>
+
      <time = "13:00"/>
+
<OpenMeeting/>
+
 
+
 
+
 
+
The participant fetches one of the meeting requests for the participant and chooses a preferred time-slot and send
+
+
  <SelectedTime>
+
      <MeetingId "5"/>
+
      <time = "10:00"/>
+
  <SelectedTime/>
+
 
+
The server will store the selected time immediately and send
+
 
+
    <reply>
+
        <SelectedTime>
+
            <MeetingId "5"/>
+
            <time = "10:00"/>
+
        <SelectedTime/>
+
    </reply>
+
 
+
=== Closing meeting requests ===
+
 
+
 
+
When this option is selected, the app will first ask the user to fill in the meeting identifier and then will fetch the meetings to which all participants have responded.
+
This is done by first sending the following message to the server:
+
 
+
  <CheckMeetingRespond>
+
    <MeetingId "5"/>
+
  <CheckMeetingRespond/>
+
 
+
then the server will send the name of the participants and the selected times to the meeting scheduler one by one as
+
 
+
  <SelectedTime>
+
      <MeetingId "5"/>
+
      <name = "ParticipantName"/>
+
      <time = "10:00"/>
+
  <SelectedTime/>
+
    ...
+
and the number of participants who respond for the meeting
+
 
+
  <NumberOfRespond "No"/>
+
 
+
Then user can select one of the time-slots and close the meeting by sending the following message:
+
 
+
  <CloseMeeting>
+
    <MeetingId "5"/><SelectedTime time = "10:00">
+
  <CloseMeeting/>
+
  
=== Checking for closed meeting requests ===
+
The server will then update the status of the correspondent request to 'discarded' and send back
  
 +
<PlayRequest From="Masoumeh" With="Mahsa" status="discarded"/>
  
Participants can check closed meetings by
 
  <CheckClosedMeeting/>
 
  
the server will send
+
=== Play Rock Paper Scissors ===
  
  <ClosedMeeting>
 
      <MeetingId "5"/>
 
      <SelectedTime time = "10:00">
 
    <ClosedMeeting/>
 
  
 
===[[DT_8025_2016 |Back to Course Page]]===
 
===[[DT_8025_2016 |Back to Course Page]]===

Revision as of 11:05, 21 October 2016

Objectives

There are three main objectives for this practical:

  • Learn about and use the concept of service in Android
  • Learn about and use the concepts related to network programming in Android
  • Integrated several concepts and techniques learned in this course to implement an Android application


Instructions

Start with a list of scenarios (use-cases) that the following application should be able to deal with: the scenarios should specify what kind of interactions the app should support in which order so as to realize users' requirements. Subsequently make an architectural design (preferably, but necessarily, using notations such as UML Class Diagrams an Sequence Diagrams) to show how the application should be decomposed into a number of activities and services. For each activity design the layout beforehand. Then, start programming. After you are doing, update the scenarios and design to reflect what you have actually implemented; use the scenarios as test-cases and make sure that the app does what it is supposed to.

Submit a single .zip file on blackboard with two folders: the first containing a single pdf reporting on the scenarios, design, test-cases and their outcomes, and the other containing the Eclipse project.


Rock Paper Scissors Online Game for Android!

Overview

The goal of this project is to implement a simple Android app for a Rock Paper Scissors online game. The functionalities that we adopt in our practical is to:

  • Register on the server: ready to play (available),
  • Read the list of available players,
  • Send/Discard a play request with another player,
  • Accept/reject a play request from another player,
  • Fetch the list of play requests either from or to the current player,
  • Make a choice (Rock/Paper/Scissors) and fetch the choice of the other player
  • Leave a game session, and
  • Exit.

Starting up

To achieve this, you will be given an IP address of an RPS server implemented and installed on a computer. The server listens on port 4444. Your app should first allow the user to enter this IP address and a unique ID which is to be used in meeting requests; use your HH account login name as the unique ID throughout this practical.

Then the app tries to connect to the server; if unsuccessful it will make three attempts with a 10 second delay in between (while providing sufficient information as toast messages). If successful, the client will receive the following tag from the server


<Accepted connection from  id +/>


where id is the unique identifier (account name) provided by the client. Then, the app will provide three possible options:

  • view online players (to send play request to),
  • view pending play requests to be answered, and
  • view sent play requests (waiting/accepted/rejected).


View Online Players

The app shows a layout in which the list of online players and their status (idle/busy/waiting) is shown. To fetch the list of online players the client send the following request

<OnlinePlayers/>

Then, the user can select one of the idle players to send a play request to.

Send Play Request

When the user select the player (in any way) the client sends the following structure to the server

<PlayRequest Mahsa/>

The serve will reply to the request

<Play request was sent to Mahsa!/>

This is shown by a toast message and the app will return to the main menu.

View Pending Play Request

The user may ask whether there has been any play request to be answered. In this case, after this option is selected from the main menu, the client send the following command

 <PlayRequestsForMe/>

The server send all pending requests for the participant one by one like

<PlayRequest From="Masoumeh" With="Mahsa" status="waiting"/>

Accept Play Request

The user may select one of the requests to her/him and accept/reject the request.

  <AcceptPlayRequest Masoumeh/> 

or

  <RejectPlayRequest Masoumeh/> 

The server will then update the status of the request to 'accepted' and 'rejected' respectively, and send back

<PlayRequest From="Masoumeh" With="Mahsa" status="accepted/rejected"/>

View Sent Play Request

The user may ask for the play request sent by him/her. In this case, after this option is selected from the main menu, the client send the following command

 <MyPlayRequests/>

The server send all requests from him/her one by one like

<PlayRequest From="Masoumeh" With="Mahsa" status="waiting"/>

Discard Play Request

The user may decide to discard one of his/her request by select on the requests and send the following command

  <DiscardPlayRequest Mahsa/> 

The server will then update the status of the correspondent request to 'discarded' and send back

<PlayRequest From="Masoumeh" With="Mahsa" status="discarded"/>


Play Rock Paper Scissors

Back to Course Page