bytestream.h
/*
Copyright (c) 2006-2023 by Jakob Schröter <js@camaya.net>
This file is part of the gloox library. http://camaya.net/gloox
This software is distributed under a license. The full license
agreement can be found in the file LICENSE in this distribution.
This software may not be copied, modified, sold or distributed
other than expressed in the named license agreement.
This software is distributed without any warranty.
*/
#ifndef BYTESTREAM_H__
#define BYTESTREAM_H__
#include "jid.h"
#include "logsink.h"
#include <string>
namespace gloox
{
class BytestreamDataHandler;
class GLOOX_API Bytestream
{
public:
enum StreamType
{
S5B,
IBB
};
Bytestream( StreamType type, LogSink& logInstance, const JID& initiator, const JID& target,
const std::string& sid )
: m_handler( 0 ), m_logInstance( logInstance ), m_initiator( initiator ), m_target( target ),
m_type( type ), m_sid( sid ), m_open( false )
{}
virtual ~Bytestream() {}
bool isOpen() const { return m_open; }
virtual bool connect() = 0;
virtual void close() = 0;
virtual bool send( const std::string& data ) = 0;
virtual ConnectionError recv( int timeout = -1 ) = 0;
const std::string& sid() const { return m_sid; }
StreamType type() const { return m_type; }
const JID& target() const { return m_target; }
const JID& initiator() const { return m_initiator; }
void registerBytestreamDataHandler( BytestreamDataHandler* bdh )
{ m_handler = bdh; }
void removeBytestreamDataHandler()
{ m_handler = 0; }
protected:
BytestreamDataHandler* m_handler;
const LogSink& m_logInstance;
const JID m_initiator;
const JID m_target;
StreamType m_type;
std::string m_sid;
bool m_open;
private:
Bytestream& operator=( const Bytestream& );
};
}
#endif // BYTESTREAM_H__
gloox::BytestreamDataHandler
A virtual interface that allows implementors to receive data sent over a SOCKS5 Bytestream as defined...
Definition bytestreamdatahandler.h:40
gloox::Bytestream::isOpen
bool isOpen() const
Definition bytestream.h:72
gloox::Bytestream::connect
virtual bool connect()=0
gloox::Bytestream::registerBytestreamDataHandler
void registerBytestreamDataHandler(BytestreamDataHandler *bdh)
Definition bytestream.h:142
gloox::Bytestream::removeBytestreamDataHandler
void removeBytestreamDataHandler()
Definition bytestream.h:148
gloox::Bytestream::m_open
bool m_open
Definition bytestream.h:171
gloox::Bytestream::m_target
const JID m_target
Definition bytestream.h:162
gloox::Bytestream::m_sid
std::string m_sid
Definition bytestream.h:168
gloox::Bytestream::Bytestream
Bytestream(StreamType type, LogSink &logInstance, const JID &initiator, const JID &target, const std::string &sid)
Definition bytestream.h:56
gloox::Bytestream::m_initiator
const JID m_initiator
Definition bytestream.h:159
gloox::Bytestream::recv
virtual ConnectionError recv(int timeout=-1)=0
gloox::Bytestream::send
virtual bool send(const std::string &data)=0
gloox::Bytestream::StreamType
StreamType
Definition bytestream.h:43
gloox::Bytestream::S5B
@ S5B
Definition bytestream.h:44
gloox::Bytestream::IBB
@ IBB
Definition bytestream.h:45
gloox::Bytestream::type
StreamType type() const
Definition bytestream.h:120
gloox::Bytestream::m_handler
BytestreamDataHandler * m_handler
Definition bytestream.h:153
gloox::Bytestream::sid
const std::string & sid() const
Definition bytestream.h:114
gloox::Bytestream::m_type
StreamType m_type
Definition bytestream.h:165
gloox::Bytestream::~Bytestream
virtual ~Bytestream()
Definition bytestream.h:65
gloox::Bytestream::m_logInstance
const LogSink & m_logInstance
Definition bytestream.h:156
gloox::Bytestream::target
const JID & target() const
Definition bytestream.h:127
gloox::Bytestream::initiator
const JID & initiator() const
Definition bytestream.h:134
gloox::Bytestream::close
virtual void close()=0
gloox::JID
An abstraction of a JID.
Definition jid.h:31
gloox::LogSink
An implementation of log sink and source.
Definition logsink.h:39
gloox
The namespace for the gloox library.
Definition adhoc.cpp:28
gloox::ConnectionError
ConnectionError
Definition gloox.h:684