Skip to content

Commit dd90d01

Browse files
committed
send SNS notifications asynchronously
1 parent 547c1a8 commit dd90d01

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/main/java/scorekeep/MoveFactory.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
import java.util.List;
55
import java.util.Set;
66
import java.lang.Class;
7+
import java.lang.Thread;
78
import java.lang.reflect.Method;
89
import java.lang.reflect.InvocationTargetException;
10+
911
import org.slf4j.Logger;
1012
import org.slf4j.LoggerFactory;
1113

@@ -16,7 +18,7 @@ public class MoveFactory {
1618
private final StateModel stateModel = new StateModel();
1719
private final GameController gameController = new GameController();
1820
private final StateController stateController = new StateController();
19-
private final RulesFactory rulesFactory = new RulesFactory();
21+
private final RulesFactory rulesFactory = new RulesFactory();
2022

2123
public MoveFactory(){
2224
}
@@ -58,7 +60,12 @@ public Move newMove(String sessionId, String gameId, String userId, String moveT
5860
State newState = new State(stateId, sessionId, gameId, newStateText, newTurn);
5961
// send notification on game end
6062
if ( newStateText.startsWith("A") || newStateText.startsWith("B")) {
61-
Sns.sendNotification("Scorekeep game completed", "Winner: " + userId);
63+
Thread comm = new Thread() {
64+
public void run() {
65+
Sns.sendNotification("Scorekeep game completed", "Winner: " + userId);
66+
}
67+
};
68+
comm.start();
6269
}
6370
// register state and move id to game
6471
gameController.setGameMove(sessionId, gameId, moveId);

0 commit comments

Comments
 (0)