X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fyaz-server.cpp;h=ec6133d8770f0b009e141d92779100d1102713f7;hb=eed883761eb8458dafbb760006174d1ab5169a24;hp=e72ed01567e2821c9314580694436da91da23815;hpb=97118338f9ac93e767e5589d449d3f9abacb3190;p=yazpp-moved-to-github.git diff --git a/src/yaz-server.cpp b/src/yaz-server.cpp index e72ed01..ec6133d 100644 --- a/src/yaz-server.cpp +++ b/src/yaz-server.cpp @@ -4,7 +4,20 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: yaz-server.cpp,v $ - * Revision 1.2 1999-01-28 13:08:47 adam + * Revision 1.6 1999-04-21 12:09:01 adam + * Many improvements. Modified to proxy server to work with "sessions" + * based on cookies. + * + * Revision 1.5 1999/04/09 11:46:57 adam + * Added object Yaz_Z_Assoc. Much more functional client. + * + * Revision 1.4 1999/03/23 14:17:57 adam + * More work on timeout handling. Work on yaz-client. + * + * Revision 1.3 1999/02/02 14:01:22 adam + * First WIN32 port of YAZ++. + * + * Revision 1.2 1999/01/28 13:08:47 adam * Yaz_PDU_Assoc better encapsulated. Memory leak fix in * yaz-socket-manager.cc. * @@ -14,16 +27,17 @@ */ #include -#include +#include #include #include -class MyServer : public Yaz_IR_Assoc { +class MyServer : public Yaz_Z_Assoc { public: MyServer(IYaz_PDU_Observable *the_PDU_Observable); void recv_Z_PDU(Z_APDU *apdu); IYaz_PDU_Observer* clone(IYaz_PDU_Observable *the_PDU_Observable); void failNotify(); + void timeoutNotify(); private: int m_no; }; @@ -49,35 +63,46 @@ void MyServer::recv_Z_PDU(Z_APDU *apdu) logf (LOG_LOG, "got presentRequest"); apdu = create_Z_PDU(Z_APDU_presentResponse); send_Z_PDU(apdu); - stop = 1; + // stop = 1; break; } } IYaz_PDU_Observer *MyServer::clone(IYaz_PDU_Observable *the_PDU_Observable) { - logf (LOG_LOG, "clone %d", m_no); + MyServer *new_server; + logf (LOG_LOG, "child no %d", m_no); m_no++; - return new MyServer(the_PDU_Observable); + new_server = new MyServer(the_PDU_Observable); + new_server->timeout(60); + return new_server; } MyServer::MyServer(IYaz_PDU_Observable *the_PDU_Observable) : - Yaz_IR_Assoc (the_PDU_Observable) + Yaz_Z_Assoc (the_PDU_Observable) { m_no = 0; } +void MyServer::timeoutNotify() +{ + logf (LOG_LOG, "connection timed out"); + delete this; +} + void MyServer::failNotify() { + logf (LOG_LOG, "connection closed by client"); delete this; } int main(int argc, char **argv) { Yaz_SocketManager mySocketManager; + Yaz_PDU_Assoc *my_PDU_Assoc = new Yaz_PDU_Assoc(&mySocketManager, 0); + + MyServer z(my_PDU_Assoc); - MyServer z(new Yaz_PDU_Assoc(&mySocketManager, 0)); - if (argc <= 1) z.server("@:9999"); else @@ -87,4 +112,5 @@ int main(int argc, char **argv) } while (!stop && mySocketManager.processEvent() > 0) ; + return 0; }