Skip to content

Commit

Permalink
#43 done. User can join ant authenticate selft with PIN
Browse files Browse the repository at this point in the history
  • Loading branch information
Mindau committed Oct 31, 2017
1 parent be5e325 commit 28c975d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
11 changes: 9 additions & 2 deletions application/app/src/main/java/isdp/guess_a_song/JoinGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void message(PubNub pubnub, PNMessageResult message) {
Log.v(Constants.LOGT, "PLAYER MESSAGE LISTENER: (" +message.toString() + ")");
Gson gson = new Gson();
Action action= gson.fromJson(message.getMessage(), Action.class);
if(action.getRecipient().equals(userName) ){
if(action.getRecipient().equals(userName) || action.getRecipient().equals(Constants.A_FOR_ALL) ){
if (action.getAction().equals(Constants.A_AUTH_RESPONSE)) {
if (action.getValue().equals(Constants.TRUE)) {

Expand Down Expand Up @@ -198,7 +198,14 @@ public void run() {
}else if (action.getAction().equals(Constants.A_START_GAME)) {
if ( action.getValue().equals(Constants.TRUE) && action.getPublisher().equals(Constants.HOST_USERNAME)) {
//TODO START A GAME TRIGGER HERE
}
runOnUiThread(new Runnable() {
@Override
public void run() {
info_field.setText("Host started the game. Redirecting finds here!");
}
});

}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ public void startGame(View view) {
players.add(new UserProfile(entry.getValue().getSender()));
}
}
client.publish(gameID,new Action(Constants.A_START_GAME,Constants.TRUE,Constants.HOST_USERNAME,Constants.A_FOR_ALL));

// PresencePojo temp;
// for (int i=0;i<this.mPresence.getCount();i++){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public void presence(PubNub pubnub, PNPresenceEventResult presence) {
.getAsJsonObject()
.get("is_auth")
.getAsBoolean();
pm = new PresencePojo(sender, presenceString, timestamp,is_auth);
presenceString = "join + "+presenceString;
pm = new PresencePojo(sender, presenceString, timestamp,is_auth);
Log.d(Constants.LOGT, "HOST PRESENCE= "+pm.toString());
}else{
pm = new PresencePojo(sender, presenceString, timestamp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class Constants {
public final static String A_LOG_IN = "log_in";
public final static String A_AUTH_RESPONSE = "auth_check";
public final static String A_START_GAME = "start_game";
public final static String A_FOR_ALL = "all";



Expand Down

0 comments on commit 28c975d

Please sign in to comment.