2 * Copyright (c) 1998-2000, Index Data.
3 * See the file LICENSE for details.
5 * $Log: yaz-server.cpp,v $
6 * Revision 1.9 2000-09-12 12:09:53 adam
7 * More work on high-level server.
9 * Revision 1.8 2000/09/08 10:23:42 adam
10 * Added skeleton of yaz-z-server.
12 * Revision 1.7 1999/12/06 13:52:45 adam
13 * Modified for new location of YAZ header files. Experimental threaded
16 * Revision 1.6 1999/04/21 12:09:01 adam
17 * Many improvements. Modified to proxy server to work with "sessions"
20 * Revision 1.5 1999/04/09 11:46:57 adam
21 * Added object Yaz_Z_Assoc. Much more functional client.
23 * Revision 1.4 1999/03/23 14:17:57 adam
24 * More work on timeout handling. Work on yaz-client.
26 * Revision 1.3 1999/02/02 14:01:22 adam
27 * First WIN32 port of YAZ++.
29 * Revision 1.2 1999/01/28 13:08:47 adam
30 * Yaz_PDU_Assoc better encapsulated. Memory leak fix in
31 * yaz-socket-manager.cc.
33 * Revision 1.1.1.1 1999/01/28 09:41:07 adam
34 * First implementation of YAZ++.
39 #include <yaz-z-server.h>
40 #include <yaz-pdu-assoc.h>
41 #include <yaz-socket-manager.h>
43 class MyServer : public Yaz_Z_Server {
45 MyServer(IYaz_PDU_Observable *the_PDU_Observable);
46 void recv_Z_init (Z_InitRequest *initRequest,
47 Z_InitResponse *initResponse);
48 void recv_Z_search (Z_SearchRequest *searchRequest,
49 Z_SearchResponse *searchResponse);
50 void recv_Z_present (Z_PresentRequest *presentRequest,
51 Z_PresentResponse *presentResponse);
53 void recv_Z_record (const char *resultSetName,
56 Z_RecordComposition *comp,
57 Z_NamePlusRecord *namePlusRecord,
58 Z_DefaultDiagFormat *diagnostics);
59 IYaz_PDU_Observer* clone(IYaz_PDU_Observable *the_PDU_Observable);
69 void MyServer::recv_Z_init (Z_InitRequest *initRequest,
70 Z_InitResponse *initResponse)
72 logf (LOG_LOG, "MyServer::recv_Z_init");
75 void MyServer::recv_Z_search (Z_SearchRequest *searchRequest,
76 Z_SearchResponse *searchResponse)
78 logf (LOG_LOG, "MyServer::recv_Z_search");
83 void MyServer::recv_Z_present (Z_PresentRequest *presentRequest,
84 Z_PresentResponse *presentResponse)
86 logf (LOG_LOG, "MyServer::recv_Z_present");
89 void MyServer::recv_Z_record (const char *resultSetName,
92 Z_RecordComposition *comp,
93 Z_NamePlusRecord *namePlusRecord,
94 Z_DefaultDiagFormat *diagnostics)
99 IYaz_PDU_Observer *MyServer::clone(IYaz_PDU_Observable *the_PDU_Observable)
101 MyServer *new_server;
102 logf (LOG_LOG, "child no %d", m_no);
104 new_server = new MyServer(the_PDU_Observable);
105 new_server->timeout(60);
109 MyServer::MyServer(IYaz_PDU_Observable *the_PDU_Observable) :
110 Yaz_Z_Server (the_PDU_Observable)
115 void MyServer::timeoutNotify()
117 logf (LOG_LOG, "connection timed out");
121 void MyServer::failNotify()
123 logf (LOG_LOG, "connection closed by client");
127 void MyServer::connectNotify()
131 int main(int argc, char **argv)
136 Yaz_SocketManager mySocketManager;
137 Yaz_PDU_Assoc *my_PDU_Assoc = new Yaz_PDU_Assoc(&mySocketManager);
139 MyServer *z = new MyServer(my_PDU_Assoc);
145 for (int i = 1; i < argc; i++)
148 while (!stop && mySocketManager.processEvent() > 0)
150 logf (LOG_LOG, "bailing out");