2
#ifndef _XMLRPCSOURCE_H_
3
#define _XMLRPCSOURCE_H_
5
// XmlRpc++ Copyright (c) 2002-2008 by Chris Morley
8
# pragma warning(disable:4786) // identifier was truncated in debug info
11
#include "XmlRpcSocket.h"
16
//! Proxy for Ssl data to avoid including headers here.
19
//! An RPC source represents a file descriptor to monitor
23
//! @param fd The socket file descriptor to monitor.
24
//! @param deleteOnClose If true, the object deletes itself when close is called.
25
XmlRpcSource(XmlRpcSocket::Socket fd = XmlRpcSocket::Invalid, bool deleteOnClose = false);
28
virtual ~XmlRpcSource();
30
//! Return the file descriptor being monitored.
31
XmlRpcSocket::Socket getfd() const { return _fd; }
32
//! Specify the file descriptor to monitor.
33
void setfd(XmlRpcSocket::Socket fd) { _fd = fd; }
35
//! Return whether the file descriptor should be kept open if it is no longer monitored.
36
bool getKeepOpen() const { return _keepOpen; }
37
//! Specify whether the file descriptor should be kept open if it is no longer monitored.
38
void setKeepOpen(bool b=true) { _keepOpen = b; }
40
//! Return whether ssl is enabled.
41
bool getSslEnabled() const { return _sslEnabled; }
42
//! Specify whether to enable ssl. Use getSslEnabled() to verify that Ssl is available.
43
void setSslEnabled(bool b=true);
45
//! Close the owned fd. If deleteOnClose was specified at construction, the object is deleted.
48
//! Return true to continue monitoring this source
49
virtual unsigned handleEvent(unsigned eventType) = 0;
53
// Execution processing helpers
54
virtual bool doConnect();
56
//! Read text from the source. Returns false on error.
57
bool nbRead(std::string& s, bool *eof);
59
//! Write text to the source. Returns false on error.
60
bool nbWrite(std::string const& s, int *bytesSoFar);
64
// Socket. This is an int for linux/unix, and unsigned on win32, and unsigned __int64 on win64.
65
// Casting to int/long/unsigned on win64 is a bad idea.
66
XmlRpcSocket::Socket _fd;
68
// In the server, a new source (XmlRpcServerConnection) is created
69
// for each connected client. When each connection is closed, the
70
// corresponding source object is deleted.
73
// In the client, keep connections open if you intend to make multiple calls.
84
#endif //_XMLRPCSOURCE_H_