12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- /*
- * 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 chatProg.controller;
-
- import java.util.concurrent.Flow;
- import java.util.logging.Logger;
- import chatProg.logger.OhmLogger;
- import chatProg.model.ChatModel;
- import chatProg.view.ChatView;
-
- /**
- *
- * @author hd, chris
- */
-
- public class ReceiveAdapter implements Flow.Subscriber<String>
- {
- private static Logger lg = OhmLogger.getLogger();
-
- private ChatView view;
- private ChatModel model;
- private Flow.Subscription subscription;
-
- public ReceiveAdapter(ChatView view, ChatModel model)
- {
- this.view = view;
- this.model = model;
- }
-
- public void subscribe()
- {
- model.addSubscription(this);
- }
-
- @Override
- public void onSubscribe(Flow.Subscription subscription)
- {
- this.subscription = subscription;
- subscription.request(1);
- }
-
- @Override
- public void onNext(String item)
- {
- view.getLblStatusDialog().setText("Nachricht empfangen");
- view.getjTextArea().append("Partner: " + item + "\n");
- subscription.request(1);
- //System.out.println(item);
- }
-
- @Override
- public void onError(Throwable throwable)
- {
- }
-
- @Override
- public void onComplete()
- {
- }
- }
|