Difference between revisions of "DT 8025 2016 Practical 3"

From CERES
Jump to: navigation, search
Line 82: Line 82:
 
  <OnlinePlayers/>
 
  <OnlinePlayers/>
  
Then, the user can select one of the idle players to send a play request to.
+
The server send the list of online players one by one like
 +
 
 +
<OnlinePlayer name="Masoumeh" status="waiting"/>
 +
<OnlinePlayer name="Mahsa" status="idle"/>
 +
<OnlinePlayer name="Mahsa" status="busy"/>
  
 
=== Send Play Request ===
 
=== Send Play Request ===
When the user select the player (in any way) the client sends the following structure to the server
+
The user can select one of the idle players to send a play request to. When the user select the player (e.g., Mahsa) the client sends the following structure to the server
  
 
  <PlayRequest Mahsa/>
 
  <PlayRequest Mahsa/>
Line 95: Line 99:
 
This is shown by a toast message and the app will return to the main menu.
 
This is shown by a toast message and the app will return to the main menu.
  
=== View Pending Play Request  ===
+
=== View Play Request For X ===
  
The user may ask whether there has been any play request to be answered.  
+
The user may ask whether there has been any play request to be .  
 
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 105: Line 109:
 
The server send all pending requests for the participant one by one like  
 
The server send all pending requests for the participant one by one like  
  
  <PlayRequest From="Masoumeh" With="Mahsa" status="waiting"/>
+
  <PlayRequest From="Masoumeh" With="Mahsa" status="pending"/>
  
=== Accept Play Request ===
+
=== Accept/Reject Play Request ===
The user may select one of the requests to her/him and accept/reject the request.
+
The user may select one of the requests for him/her and accept/reject the request.
 
 
 
   <AcceptPlayRequest Masoumeh/>  
 
   <AcceptPlayRequest Masoumeh/>  
Line 120: Line 124:
 
  <PlayRequest From="Masoumeh" With="Mahsa" status="accepted/rejected"/>
 
  <PlayRequest From="Masoumeh" With="Mahsa" status="accepted/rejected"/>
  
=== View Sent Play Request  ===
+
If the user accept a request the app automatically moves to the play game page in which the user starts to play.
  
The user may ask for the play request sent by him/her.  
+
=== View Sent Play Request  ===
 +
The user may ask for the play requests 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  
Line 130: Line 135:
 
The server send all requests from him/her 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="pending/accepted/rejected/discarded"/>
 +
 
 +
An accepted play request shows on active (ongoing) game session. The user can select an accepted request and starts to play.
  
 
=== Discard Play Request ===
 
=== Discard Play Request ===
The user may decide to discard one of his/her request by select on the requests and send the following command
+
The user may decide to discard one of his/her request by select on the pending (not accepted or rejected) requests and send the following command
 
 
 
   <DiscardPlayRequest Mahsa/>  
 
   <DiscardPlayRequest Mahsa/>  
Line 140: Line 147:
  
 
  <PlayRequest From="Masoumeh" With="Mahsa" status="discarded"/>
 
  <PlayRequest From="Masoumeh" With="Mahsa" status="discarded"/>
 
  
 
=== Play Rock Paper Scissors ===
 
=== Play Rock Paper Scissors ===
 +
The game happens in the play view. In this view, the user make his/her choice (rock/paper/scissors) and also see the choice of the other player (obviously not before making his/her choice!). When the use choose, the client sends the following command
 +
 +
  <Choice Rock/Paper/Scissors/>
 +
 +
To fetch the status of the game (choices), the client sends the check status request
 +
 +
  <CheckGameStatus/>
 +
 +
=== Leave Game Session ===
 +
The user may leave a game session by sending this command
 +
 +
  <LeaveSession/>
 +
 +
This option is available in the play view.
 +
 +
=== Exit Game ===
 +
To exit the game the client send
  
 +
<Exit/>
  
 
===[[DT_8025_2016 |Back to Course Page]]===
 
===[[DT_8025_2016 |Back to Course Page]]===

Revision as of 11:37, 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/>

The server send the list of online players one by one like

<OnlinePlayer name="Masoumeh" status="waiting"/>
<OnlinePlayer name="Mahsa" status="idle"/>
<OnlinePlayer name="Mahsa" status="busy"/>

Send Play Request

The user can select one of the idle players to send a play request to. When the user select the player (e.g., Mahsa) 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 Play Request For X

The user may ask whether there has been any play request to be . 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="pending"/>

Accept/Reject Play Request

The user may select one of the requests for him/her 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"/>

If the user accept a request the app automatically moves to the play game page in which the user starts to play.

View Sent Play Request

The user may ask for the play requests 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="pending/accepted/rejected/discarded"/>

An accepted play request shows on active (ongoing) game session. The user can select an accepted request and starts to play.

Discard Play Request

The user may decide to discard one of his/her request by select on the pending (not accepted or rejected) 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

The game happens in the play view. In this view, the user make his/her choice (rock/paper/scissors) and also see the choice of the other player (obviously not before making his/her choice!). When the use choose, the client sends the following command

  <Choice Rock/Paper/Scissors/>

To fetch the status of the game (choices), the client sends the check status request

 <CheckGameStatus/>

Leave Game Session

The user may leave a game session by sending this command

 <LeaveSession/>

This option is available in the play view.

Exit Game

To exit the game the client send

<Exit/>

Back to Course Page