Skip to content

Commit

Permalink
reacting on started/exiting in payout-event
Browse files Browse the repository at this point in the history
  • Loading branch information
sixtyeight committed May 9, 2016
1 parent 82af70f commit 24348b3
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions src/main/java/at/metalab/changeomatic/ChangeomaticMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,18 @@ public static void main(String[] args) throws Exception {

RedissonClient r = Redisson.create(c);

final RTopic<String> changeomaticEvent = r
.getTopic("changeomatic-event");
changeomaticEvent.publish(createChangeomaticEvent("starting-up")
.stringify());
final RTopic<String> changeomaticEvent = r.getTopic("changeomatic-event");
changeomaticEvent.publish(createChangeomaticEvent("starting-up").stringify());

final RTopic<String> payoutEvent = r.getTopic("payout-event");

final RTopic<String> hopperRequest = r.getTopic("hopper-request");
final RTopic<String> hopperResponse = r.getTopic("hopper-response");
final RTopic<String> hopperEvent = r.getTopic("hopper-event");

final RTopic<String> validatorEvent = r.getTopic("validator-event");
final RTopic<String> validatorRequest = r.getTopic("validator-request");
final RTopic<String> validatorResponse = r
.getTopic("validator-response");
final RTopic<String> validatorResponse = r.getTopic("validator-response");

hopperResponse.addListener(HOPPER_RESPONSE_DISPATCHER);
validatorResponse.addListener(VALIDATOR_RESPONSE_DISPATCHER);
Expand All @@ -159,6 +158,30 @@ public static void main(String[] args) throws Exception {
submitAllTestPayouts(changeomaticFrame, hopperRequest, hopperResponse,
validatorRequest, changeomaticEvent);

payoutEvent.addListener(new MessageListener<String>() {

public void onMessage(String channel, String strMessage) {
try {
LOG.info("payout-event: " + strMessage);
KassomatJson message = KassomatJson.parse(strMessage);

switch (message.event) {
case "started":
submitAllTestPayouts(changeomaticFrame, hopperRequest, hopperResponse,
validatorRequest, changeomaticEvent);
break;

case "exiting":
changeomaticFrame.hintSorry();
changeomaticFrame.repaint();
break;
}
} catch (Exception exception) {
oops("payout-event-listener", exception);
}
}
});

// handle events which have happened in the banknote validator
validatorEvent.addListener(new MessageListener<String>() {

Expand Down

0 comments on commit 24348b3

Please sign in to comment.