2012-05-10 12:06:41 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Icinga 2 *
|
|
|
|
* Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License *
|
|
|
|
* as published by the Free Software Foundation; either version 2 *
|
|
|
|
* of the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the Free Software Foundation *
|
|
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
|
******************************************************************************/
|
|
|
|
|
2012-04-02 08:56:30 +02:00
|
|
|
#ifndef TCPCLIENT_H
|
|
|
|
#define TCPCLIENT_H
|
2012-03-28 13:24:49 +02:00
|
|
|
|
|
|
|
namespace icinga
|
|
|
|
{
|
|
|
|
|
2012-04-24 14:02:15 +02:00
|
|
|
enum I2_BASE_API TCPClientRole
|
|
|
|
{
|
|
|
|
RoleInbound,
|
|
|
|
RoleOutbound
|
|
|
|
};
|
|
|
|
|
2012-04-06 08:56:52 +02:00
|
|
|
class I2_BASE_API TCPClient : public TCPSocket
|
2012-03-28 13:24:49 +02:00
|
|
|
{
|
|
|
|
private:
|
2012-04-24 14:02:15 +02:00
|
|
|
TCPClientRole m_Role;
|
|
|
|
|
2012-04-02 20:50:35 +02:00
|
|
|
FIFO::Ptr m_SendQueue;
|
|
|
|
FIFO::Ptr m_RecvQueue;
|
2012-03-28 13:24:49 +02:00
|
|
|
|
2012-04-24 14:02:15 +02:00
|
|
|
virtual int ReadableEventHandler(const EventArgs& ea);
|
|
|
|
virtual int WritableEventHandler(const EventArgs& ea);
|
2012-03-28 13:24:49 +02:00
|
|
|
|
|
|
|
public:
|
2012-04-02 20:50:35 +02:00
|
|
|
typedef shared_ptr<TCPClient> Ptr;
|
|
|
|
typedef weak_ptr<TCPClient> WeakPtr;
|
2012-03-28 13:24:49 +02:00
|
|
|
|
2012-04-24 14:02:15 +02:00
|
|
|
TCPClient(TCPClientRole role);
|
|
|
|
|
|
|
|
TCPClientRole GetRole(void) const;
|
2012-03-28 13:24:49 +02:00
|
|
|
|
|
|
|
virtual void Start(void);
|
|
|
|
|
2012-05-07 13:48:17 +02:00
|
|
|
void Connect(const string& node, const string& service);
|
2012-03-28 13:24:49 +02:00
|
|
|
|
2012-04-02 20:50:35 +02:00
|
|
|
FIFO::Ptr GetSendQueue(void);
|
|
|
|
FIFO::Ptr GetRecvQueue(void);
|
2012-03-28 13:24:49 +02:00
|
|
|
|
|
|
|
virtual bool WantsToRead(void) const;
|
|
|
|
virtual bool WantsToWrite(void) const;
|
|
|
|
|
2012-04-18 15:22:25 +02:00
|
|
|
Event<EventArgs> OnDataAvailable;
|
2012-03-28 13:24:49 +02:00
|
|
|
};
|
|
|
|
|
2012-04-24 14:02:15 +02:00
|
|
|
TCPClient::Ptr TCPClientFactory(TCPClientRole role);
|
|
|
|
|
2012-03-28 13:24:49 +02:00
|
|
|
}
|
|
|
|
|
2012-04-02 08:56:30 +02:00
|
|
|
#endif /* TCPCLIENT_H */
|