2 * Copyright (c) 1998-2000, Index Data.
3 * See the file LICENSE for details.
5 * $Id: yaz-pdu-observer.h,v 1.3 2001-03-26 14:43:49 adam Exp $
8 #ifndef YAZ_PDU_OBSERVER_H
9 #define YAZ_PDU_OBSERVER_H
11 class IYaz_PDU_Observer;
13 /** Protocol Data Unit Observable.
14 This interface implements a Protocol Data Unit (PDU) network driver.
15 The PDU's is not encoded/decoded by this interface. They are simply
16 transmitted/received over the network. To use this interface the
17 IYaz_PDU_Observer interface must be implemented.
19 class YAZ_EXPORT IYaz_PDU_Observable {
21 /// Send encoded PDU buffer of specified length
22 virtual int send_PDU(const char *buf, int len) = 0;
23 /// Connect with server specified by addr.
24 virtual void connect(IYaz_PDU_Observer *observer, const char *addr) = 0;
25 /// Listen on address addr.
26 virtual void listen(IYaz_PDU_Observer *observer, const char *addr) = 0;
28 virtual void close() = 0;
29 /// Make clone of this object using this interface
30 virtual IYaz_PDU_Observable *clone() = 0;
31 /// Destroy completely
32 virtual void destroy() = 0;
34 virtual void idleTime (int timeout) = 0;
37 /** Protocol Data Unit Observer.
38 This interface is used together with the IYaz_PDU_Observable interface
39 and acts as a callback interface for it.
41 class YAZ_EXPORT IYaz_PDU_Observer {
43 /// A PDU has been received
44 virtual void recv_PDU(const char *buf, int len) = 0;
45 /// Called when Iyaz_PDU_Observable::connect was successful.
46 virtual void connectNotify() = 0;
47 /// Called whenever the connection was closed
48 virtual void failNotify() = 0;
49 /// Called whenever there is a timeout
50 virtual void timeoutNotify() = 0;
51 /// Make clone of observer using IYaz_PDU_Observable interface
52 virtual IYaz_PDU_Observer *sessionNotify(
53 IYaz_PDU_Observable *the_PDU_Observable, int fd) = 0;