HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 "FS_EventGenerator.h"
24 #include <UT/UT_NonCopyable.h>
25 #include <UT/UT_String.h>
26 #include <UT/UT_WorkBuffer.h>
27 
28 class UT_NetSocket;
29 
31 {
32 public:
33  typedef void (*Callback)(void *callback_data, const char *data, int length,
34  UT_NetSocket &connection_socket);
35 
36  // The callback is called when data has been read from the socket. The
37  // socket is passed into the callback so it can write data out to the
38  // socket. The ip mask restricts who is allowed to connect to this
39  // socket. If the ip mask is null it defaults to +.+.+.+.
40  FS_ConnectedSocketListener(UT_NetSocket &server_socket, Callback callback,
41  void *callback_data = 0,
42  const char *ip_mask = 0);
43  ~FS_ConnectedSocketListener() override;
44 
46 
47  const char *getClassName() const override
48  { return "FS_ConnectedSocketListener"; }
49  bool getIsInstalled() const
50  { return myConnectionSocket != NULL; }
51 
52 protected:
53  // This method returns true when there is data on the socket.
54  bool areEventsWaiting() override;
55 
56  // When there is data on the socket, this method is called.
57  int processEvents() override;
58 
59  // Return the file descriptor of the server socket.
60  int getFileDescriptor() override;
61 
62 private:
63  void closeConnectionSocket();
64 
65  // Data:
66  void *myCallbackData;
67  Callback myCallback;
68  UT_NetSocket *myConnectionSocket;
69  UT_WorkBuffer myDataBuffer;
70  bool myProcessingCallback;
71 };
72 
73 #endif
virtual int getFileDescriptor()
void
Definition: png.h:1083
GLboolean * data
Definition: glcorearb.h:131
GLuint GLsizei GLsizei * length
Definition: glcorearb.h:795
virtual bool areEventsWaiting()
virtual int processEvents()=0
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
#define const
Definition: zconf.h:214
#define FS_API
Definition: FS_API.h:10