HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FS_ConnectedSocketListener.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: FS_ConnectedSocketListener.h ( FS Library, C++ )
7  *
8  * COMMENTS:
9  * This event generator listens for data that's sent to a connected
10  * socket. When data is sent to this socket, a callback is called.
11  * If the socket is closed, this event generator removes itself and
12  * schedules the UI_Queue to delete it. You must create this event
13  * generator with new and you should not keep a pointer to it.
14  *
15  * You probably don't want to use this class directly. Instead, you
16  * probably want to use FS_ServerSocketListener.
17  */
18 
19 #ifndef __FS_ConnectedSocketListener_h__
20 #define __FS_ConnectedSocketListener_h__
21 
22 #include "FS_API.h"
23 #include <UT/UT_WorkBuffer.h>
24 #include <UT/UT_String.h>
25 #include "FS_EventGenerator.h"
26 class UT_NetSocket;
27 
29 {
30 public:
31  typedef void (*Callback)(void *callback_data, const char *data, int length,
32  UT_NetSocket &connection_socket);
33 
34  // The callback is called when data has been read from the socket. The
35  // socket is passed into the callback so it can write data out to the
36  // socket. The ip mask restricts who is allowed to connect to this
37  // socket. If the ip mask is null it defaults to +.+.+.+.
38  FS_ConnectedSocketListener(UT_NetSocket &server_socket, Callback callback,
39  void *callback_data = 0,
40  const char *ip_mask = 0);
41  virtual ~FS_ConnectedSocketListener();
42 
43  virtual const char *getClassName() const
44  { return "FS_ConnectedSocketListener"; }
45  bool getIsInstalled() const
46  { return myConnectionSocket != NULL; }
47 
48 protected:
49  // This method returns true when there is data on the socket.
50  virtual bool areEventsWaiting();
51 
52  // When there is data on the socket, this method is called.
53  virtual int processEvents();
54 
55  // Return the file descriptor of the server socket.
56  virtual int getFileDescriptor();
57 
58 private:
59  void closeConnectionSocket();
60 
61  // Data:
62  void *myCallbackData;
63  Callback myCallback;
64  UT_NetSocket *myConnectionSocket;
65  UT_WorkBuffer myDataBuffer;
66  bool myProcessingCallback;
67 };
68 
69 #endif
virtual int getFileDescriptor()
virtual const char * getClassName() const
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
virtual bool areEventsWaiting()
virtual int processEvents()=0
GLboolean * data
Definition: glcorearb.h:130
#define FS_API
Definition: FS_API.h:10
GLuint GLsizei GLsizei * length
Definition: glcorearb.h:794