Kemekaze / EDA397G1

2 stars 0 forks source link
game planning the

Build Status

EDA397G1 - The Planning Game

The project is to do an Android application that works as a version of the XP Planning availSession which will be integrated with Github. Java will be used for this purpose. The goal is to make the process of the planning availSession easier for both customers and developers and also provide metrics over completed availSessions which could be used for further evaluation.

Dependencies

App

Server

Build Instructions

App

Server

Structure

Android

Send a request to the server

RequestEvent requestEvent = new RequestEvent(EVENTSTRING, JSON_OBJECT);
EventBus.getDefault().post(requestEvent);

Where EVENTSTRING is a Constant located in Constants.SockeSocketEvents

public class Constants {
  public class SocketEvents {
      ...
      public static final String AUTHENTICATE_GITHUB = "authenticate.github";
      ...
  }
}

JSON_OBJECT is a JSON object with your query to the server. \n A complete call can look like

JSONObject obj = ... your JSONObject
RequestEvent requestEvent = new RequestEvent(Constants.SocketEvents.AUTHENTICATE_GITHUB,obj);
EventBus.getDefault().post(requestEvent);

Getting a response from the server

in SocketService we need to define our reponse for the request

private void setupListeners(){
....
socket.on(Constants.SocketEvents.AUTHENTICATE_GITHUB, eventAuthenticatedGithub);
...
}

where we have the same EVENTSTRING and then a callback listener (eventAuthenticatedGithub)

private Emitter.Listener eventAuthenticatedGithub = new Emitter.Listener() {
    @Override
    public void call(Object... args) {
        Log.i(TAG, "eventAuthenticatedGithub");
        for(int i = 0; i<args.length; i++)
            Log.i(TAG,  args[i].toString());
        // send the data back to the activity
        // by creating a new LoginEvent (just for this case, different events for different events)
        // All events should extend the class Event
        EventBus.getDefault().post(new LoginEvent(args));
    }
};

In your activity you will have a method with the anontaion @Subscribe for handling the EventBus.getDefault().post() event


@Subscribe
public void loginEvent(LoginEvent event)
{

}
//This will be usually handled in a different thread the you can use
@Subscribe(threadMode = ThreadMode.MainThread)

For more about the Eventbus visit: https://github.com/greenrobot/EventBus

Server

to be added