You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ReceiveAdapter.java 1023B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
  3. * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
  4. */
  5. package ChatProgramm.model;
  6. import ChatProgramm.view.ChatView;
  7. import java.util.concurrent.Flow;
  8. import java.util.concurrent.Flow.Subscriber;
  9. /**
  10. *
  11. * @author ahren
  12. */
  13. public class ReceiveAdapter implements Subscriber<Nachricht> {
  14. private ChatView view;
  15. private Flow.Subscription subscription;
  16. public ReceiveAdapter(ChatView view) {
  17. this.view = view;
  18. }
  19. @Override
  20. public void onSubscribe(Flow.Subscription subscription) {
  21. this.subscription = subscription;
  22. this.subscription.request(1);
  23. }
  24. @Override
  25. public void onNext(Nachricht item) {
  26. view.getTxtChat().append(item.getNachricht());
  27. this.subscription.request(1);
  28. }
  29. @Override
  30. public void onError(Throwable throwable) {
  31. }
  32. @Override
  33. public void onComplete(){
  34. }
  35. }