blob: add1c29131fab73a5ce7a7d09dae8da7090ef9c6 [file] [log] [blame]
Andrew Brown3f2521a2015-01-17 22:10:15 -08001/*
2 * File name: ClientObservable.java
3 *
4 * Purpose:
5 *
6 * © Copyright Intel Corporation. All rights reserved.
7 * Intel Corporation, 2200 Mission College Boulevard,
8 * Santa Clara, CA 95052-8119, USA
9 */
10package com.intel.jndn.utils;
11
12import java.util.ArrayList;
13import java.util.List;
14import java.util.Observable;
15import net.named_data.jndn.Data;
16import net.named_data.jndn.Interest;
17import net.named_data.jndn.Name;
18import net.named_data.jndn.OnData;
19import net.named_data.jndn.OnInterest;
20import net.named_data.jndn.OnTimeout;
21import net.named_data.jndn.transport.Transport;
22
23/**
24 *
25 * @author Andrew Brown <andrew.brown@intel.com>
26 */
27public class ClientObservable extends Observable implements OnData, OnTimeout, OnInterest {
28
29 protected List<ClientObservableEvent> events = new ArrayList<>();
30 protected List<Interest> incomingInterestPackets = new ArrayList<>();
31 protected List<Data> incomingDataPackets;
32
33 @Override
34 public void onData(Interest interest, Data data) {
35 notifyObservers(new ClientObservableEvent(data));
36 }
37
38 public void onError(Exception e){
39 notifyObservers(new ClientObservableEvent(e));
40 }
41
42 @Override
43 public void onTimeout(Interest interest) {
44 notifyObservers(new ClientObservableEvent());
45 }
46
47 @Override
48 public void onInterest(Name prefix, Interest interest, Transport transport, long registeredPrefixId) {
49 notifyObservers(new ClientObservableEvent(interest));
50 }
51}