libktorrent
2.2.0
src
peer
peerprotocolextension.h
1
/***************************************************************************
2
* Copyright (C) 2009 by Joris Guisson *
3
* joris.guisson@gmail.com *
4
* *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
9
* *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
14
* *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19
***************************************************************************/
20
21
#ifndef BT_PEERPROTOCOLEXTENSION_H
22
#define BT_PEERPROTOCOLEXTENSION_H
23
24
#include <ktorrent_export.h>
25
#include <util/constants.h>
26
27
namespace
bt
28
{
29
class
Peer;
30
31
const
Uint32 UT_PEX_ID = 1;
32
const
Uint32 UT_METADATA_ID = 2;
33
37
class
KTORRENT_EXPORT
PeerProtocolExtension
38
{
39
public
:
40
PeerProtocolExtension
(bt::Uint32
id
,
Peer
* peer);
41
virtual
~
PeerProtocolExtension
();
42
44
virtual
void
update
();
45
47
virtual
bool
needsUpdate
()
const
{
return
false
;}
48
50
virtual
void
handlePacket
(
const
bt::Uint8* packet, Uint32 size) = 0;
51
53
void
sendPacket
(
const
QByteArray & data);
54
56
void
changeID
(Uint32
id
);
57
58
protected
:
59
bt::Uint32 id;
60
Peer
* peer;
61
};
62
63
}
64
65
#endif // BT_PEERPROTOCOLEXTENSION_H
bt::PeerProtocolExtension::needsUpdate
virtual bool needsUpdate() const
Does this needs to be update.
Definition:
peerprotocolextension.h:47
bt::Peer
Manages the connection with a peer.
Definition:
peer.h:59
bt::PeerProtocolExtension::changeID
void changeID(Uint32 id)
Change the ID.
bt::PeerProtocolExtension
Definition:
peerprotocolextension.h:38
bt::PeerProtocolExtension::sendPacket
void sendPacket(const QByteArray &data)
Send an extension protocol packet.
bt::PeerProtocolExtension::update
virtual void update()
Virtual update function does nothing, needs to be overridden if update.
bt::PeerProtocolExtension::handlePacket
virtual void handlePacket(const bt::Uint8 *packet, Uint32 size)=0
Handle a packet.
Generated by
1.8.20