graphic_chat/src/graphicChat/controller/ReceiveAdapter.java

68 lines
1.3 KiB
Java
Raw Normal View History

2020-12-22 15:18:10 +01:00
/*
* 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 graphicChat.controller;
import java.util.concurrent.Flow;
import java.util.logging.Logger;
import graphicChat.logger.OhmLogger;
import graphicChat.model.ChatModel;
import graphicChat.model.Figure;
import graphicChat.view.ChatView;
import java.util.List;
/**
*
* @author hd, chris
*/
public class ReceiveAdapter implements Flow.Subscriber<List<Figure>>
{
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(List<Figure> msg)
{
view.getLblStatus().setText("Nachricht empfangen");
model.addList(msg);
subscription.request(1);
}
@Override
public void onError(Throwable throwable)
{
}
@Override
public void onComplete()
{
}
}