123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
- package bandit.controller;
-
-
- import java.util.concurrent.Flow;
- import java.util.concurrent.Flow.Subscriber;
- import java.util.logging.Logger;
-
- import bandit.model.WuerfelModel;
- import bandit.view.WuerfelView;
-
- /**
- *
- * @author hd
- */
- public class BanditAdapter implements Subscriber<Integer>
- {
- private WuerfelView view;
- private WuerfelModel model;
- private Flow.Subscription subscription;
- private static Logger lg = Logger.getLogger("Wuerfelthreads");
-
- public BanditAdapter(WuerfelView view, WuerfelModel model)
- {
- this.view = view;
- this.model = model;
- }
-
- public void einschreiben()
- {
- model.addWertSubscription(this);
- }
-
- @Override
- public void onSubscribe(Flow.Subscription subscription)
- {
- this.subscription = subscription;
- subscription.request(1);
- lg.info("onSubsribe");
- }
-
- @Override
- public void onNext(Integer item)
- {
- view.getLbZahl().setText(String.valueOf(item));
- subscription.request(1);
- lg.info("onNext");
- }
-
- @Override
- public void onError(Throwable throwable)
- {
- }
-
- @Override
- public void onComplete()
- {
- }
-
-
- }
|