IBR-DTNSuite  0.10
BinaryStreamClient.h
Go to the documentation of this file.
1 /*
2  * BinaryStreamClient.h
3  *
4  * Copyright (C) 2011 IBR, TU Braunschweig
5  *
6  * Written-by: Johannes Morgenroth <morgenroth@ibr.cs.tu-bs.de>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21 
22 #ifndef BINARYSTREAMCLIENT_H_
23 #define BINARYSTREAMCLIENT_H_
24 
25 #include "api/ClientHandler.h"
28 
29 namespace dtn
30 {
31  namespace api
32  {
34  {
35  public:
37  virtual ~BinaryStreamClient();
38 
40  virtual void eventTimeout() throw ();
41  virtual void eventError() throw ();
42  virtual void eventConnectionDown() throw ();
43  virtual void eventConnectionUp(const dtn::streams::StreamContactHeader &header) throw ();
44 
45  virtual void eventBundleRefused() throw ();
46  virtual void eventBundleForwarded() throw ();
47  virtual void eventBundleAck(const dtn::data::Length &ack) throw ();
48 
49  const dtn::data::EID& getPeer() const;
50 
51  void queue(const dtn::data::Bundle &bundle);
52 
54  void run();
55  void finally();
56  void __cancellation() throw ();
57  bool good() const;
58 
59  private:
60  class Sender : public ibrcommon::JoinableThread, public ibrcommon::Queue<dtn::data::Bundle>
61  {
62  public:
63  Sender(BinaryStreamClient &client);
64  virtual ~Sender();
65 
66  protected:
67  void run() throw ();
68  void __cancellation() throw ();
69 
71  bool good() const;
72 
73  private:
75  };
76 
77  friend class Sender;
78 
80 
83 
85  uint64_t _lastack;
86 
87  dtn::data::EID _eid;
88  };
89  }
90 }
91 
92 #endif /* BINARYSTREAMCLIENT_H_ */