Annotation of libwww/Library/src/HTEvtLst.html, revision 2.8
2.1 frystyk 1: <HTML>
2: <HEAD>
3: <!-- Changed by: Henrik Frystyk Nielsen, 16-May-1996 -->
2.4 frystyk 4: <TITLE>W3C Sample Code Library libwww Default Event Manager</TITLE>
2.1 frystyk 5: </HEAD>
6: <BODY>
7: <H1>
8: Default Event Manager
9: </H1>
10: <PRE>
11: /*
12: ** (c) COPYRIGHT MIT 1995.
13: ** Please first read the full copyright statement in the file COPYRIGH.
14: */
15: </PRE>
16: <P>
2.7 frystyk 17: This module provides a default event registry and an eventloop which may
18: be used by an application if desired. See also the libwww timers defined
19: in the <A HREF="HTTimer.html">HTTimer module</A>. An application may use
20: this module for:
2.1 frystyk 21: <UL>
2.7 frystyk 22: <LI>
23: <STRONG>Eventloop and registry</STRONG> - Application registers
24: <A HREF="#registry">HTEvntrg_register and HTEvntrg_unregister</A> and calls
25: <A HREF="#eventLoop">HTEventList_loop</A> to dispatch events as they occur.
26: <LI>
27: <STRONG>Event registry</STRONG> - Application just registers its own
28: <A HREF="HTEvent.html#eventHandlers">event handlers</A> and chains them to
29: <A HREF="#registry">HTEvntrg_register and HTEvntrg_unregister</A>. When the
30: application's eventloop gets activity on a socket, it calls
31: <A HREF="#dispatch">HTEvent_dispatch</A> to handle it.
32: <LI>
33: <STRONG>Nothing</STRONG> - Application registers its own
34: <A HREF="HTEvent.html#eventHandlers">event handler</A> uses its own eventloop
35: to dispatch those events.
2.1 frystyk 36: </UL>
2.7 frystyk 37: <P>
38: This module is implemented by <A HREF="HTEvtLst.c">HTEvtLst.c</A>, and it
2.6 frystyk 39: is a part of the <A HREF="http://www.w3.org/Library/">W3C Sample Code
2.1 frystyk 40: Library</A>.
41: <PRE>
2.2 frystyk 42: #ifndef HTEVTLST_H
43: #define HTEVTLST_H
2.1 frystyk 44:
2.5 frystyk 45: #include "wwwsys.h"
2.1 frystyk 46: #include "HTEvent.h"
47: #include "HTReq.h"
2.8 ! vbancrof 48:
! 49: #ifdef __cplusplus
! 50: extern "C" {
! 51: #endif
! 52:
2.1 frystyk 53: </PRE>
54: <H3>
55: Windows Specific Handles
56: </H3>
57: <PRE>
58: #if defined(WWW_WIN_ASYNC) || defined(WWW_WIN_DLL)
59: extern BOOL HTEventList_winHandle (HTRequest * request);
60: extern BOOL HTEventList_setWinHandle (HWND window, unsigned long message);
61: extern HWND HTEventList_getWinHandle (unsigned long * pMessage);
62: extern LRESULT CALLBACK AsyncWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
63: #endif
64: </PRE>
65: <H2>
66: <A NAME="registry">Event Registry</A>
67: </H2>
2.7 frystyk 68: <P>
69: The libwww event registry binds a socket and operation (<TT>FD_READ</TT>,
70: <TT>FD_WRITE</TT>, ...) to a callback function. Events are registered,
71: unregistered, and dispatched as they come in.
2.1 frystyk 72: <H3>
73: Register an Event Handler
74: </H3>
75: <P>
76: For a given socket, reqister a request structure, a set of operations, a
77: HTEventCallback function, and a priority. For this implementation, we allow
78: only a single HTEventCallback function for all operations. and the priority
79: field is ignored.
80: <PRE>
81: extern HTEvent_registerCallback HTEventList_register;
82: </PRE>
83: <H3>
84: Unregister an Event Handler
85: </H3>
86: <P>
87: Remove the registered information for the specified socket for the actions
88: specified in ops. if no actions remain after the unregister, the registered
89: info is deleted, and, if the socket has been registered for notification,
90: the HTEventCallback will be invoked.
91: <PRE>
92: extern HTEvent_unregisterCallback HTEventList_unregister;
93: </PRE>
94: <H3>
95: Unregister ALL Event Handlers
96: </H3>
97: <P>
98: Unregister all sockets. N.B. we just remove them for our internal data
99: structures: it is up to the application to actually close the socket.
100: <PRE>
101: extern int HTEventList_unregisterAll (void);
102: </PRE>
103: <H3>
2.7 frystyk 104: <A NAME="dispatch">Lookup and Dispatch Event Handlers</A>
2.1 frystyk 105: </H3>
106: <P>
2.7 frystyk 107: Callbacks can be looked up or dispatched based on the socket and operation
2.1 frystyk 108: (read/write/oob)
109: <PRE>
2.3 eric 110: extern int HTEventList_dispatch (SOCKET s, HTEventType type, ms_t now);
2.1 frystyk 111: extern HTEvent * HTEventList_lookup (SOCKET s, HTEventType type);
112: </PRE>
113: <H2>
2.7 frystyk 114: <A NAME="eventLoop">Libwww Default EventLoop</A>
2.1 frystyk 115: </H2>
116: <P>
2.7 frystyk 117: The libwww default eventloop dispatches events to the <A HREF="#registry">event
118: registry</A>.
2.1 frystyk 119: <H3>
120: Start and Stop the Event Manager
121: </H3>
122: <PRE>
123: extern BOOL HTEventInit (void);
124: extern BOOL HTEventTerminate (void);
125: </PRE>
126: <H3>
2.7 frystyk 127: Start the Eventloop
2.1 frystyk 128: </H3>
129: <P>
130: That is, we wait for activity from one of our registered channels, and dispatch
131: on that. Under Windows/NT, we must treat the console and sockets as distinct.
132: That means we can't avoid a busy wait, but we do our best.
133: <PRE>
2.7 frystyk 134: extern int HTEventList_newLoop (void);
135: </PRE>
136: <P>
137: The next version is an old version of the eventloop start. The request is
138: not used for anything and can be NULL.
139: <PRE>
2.1 frystyk 140: extern int HTEventList_loop (HTRequest * request);
141: </PRE>
142: <H3>
2.7 frystyk 143: Stop the Eventloop
2.1 frystyk 144: </H3>
145: <P>
2.7 frystyk 146: Stops the (select based) eventloop immediately. The function does not guarantee
147: that all requests have terminated so it is important that the application
148: does this before this function is called. This can be done using the
149: <TT>HTNet_isIdle()</TT> function in the <A HREF="HTNet.html">HTNet Module</A>
2.1 frystyk 150: <PRE>
151: extern void HTEventList_stopLoop (void);
152: </PRE>
153: <PRE>
2.8 ! vbancrof 154: #ifdef __cplusplus
! 155: }
! 156: #endif
! 157:
2.1 frystyk 158: #endif /* HTEVTLST_H */
159: </PRE>
160: <P>
161: <HR>
162: <ADDRESS>
2.8 ! vbancrof 163: @(#) $Id: HTEvtLst.html,v 2.7 1998/11/21 02:44:42 frystyk Exp $
2.1 frystyk 164: </ADDRESS>
165: </BODY></HTML>
Webmaster