Protocols::BitTorrent::Transfers::Session Class Reference

#include <Session.h> [code]

Inherits Protocols::Generics::TransportStatus.

Inheritance diagram for Protocols::BitTorrent::Transfers::Session:

Inheritance graph
[legend]
Collaboration diagram for Protocols::BitTorrent::Transfers::Session:

Collaboration graph
[legend]
List of all members.

Detailed Description

Implements a BitTorrent transfer session between two peers.

Todo:
Use the state design patter the avoid the switch-es.

Definition at line 48 of file Session.h.

Public Member Functions

 Session (Transport &, SessionStatus &, const PeerInfo &localPeerInfo)
 ~Session ()
void establish (const PeerInfo &remotePeerInfo, const FileId &fileId)
void waitRequest ()
void accept ()

Private Types

enum  State {
  DisconnectedTransport,
  EstablishingSession,
  AwaitingRequest,
  AwaitingAccept,
  ExchangingPackets
}

Private Member Functions

void connected ()
void readyRead ()
void readyWrite ()
void disconnected ()
bool readHandshake ()
 Tries to read the handshake of the remote peer.
void writeHandshake ()
 Writes our handshake to the transport.
void readPacket ()
void writePacket ()

Private Attributes

Transporttransport
SessionStatusstatus
PeerInfo localPeerInfo
PeerInfo remotePeerInfo
FileId fileId
State state


Member Enumeration Documentation

enum Protocols::BitTorrent::Transfers::Session::State [private]
 

Enumerator:
DisconnectedTransport 
EstablishingSession 
AwaitingRequest 
AwaitingAccept 
ExchangingPackets 

Definition at line 68 of file Session.h.


Constructor & Destructor Documentation

Session::Session Transport ,
SessionStatus ,
const PeerInfo localPeerInfo
 

Definition at line 48 of file Session.cpp.

Session::~Session  ) 
 

Definition at line 55 of file Session.cpp.


Member Function Documentation

void Session::accept  ) 
 

Definition at line 83 of file Session.cpp.

void Session::connected  )  [private]
 

Definition at line 92 of file Session.cpp.

void Session::disconnected  )  [private]
 

Definition at line 131 of file Session.cpp.

void Session::establish const PeerInfo remotePeerInfo,
const FileId fileId
 

Definition at line 59 of file Session.cpp.

bool Session::readHandshake  )  [private]
 

Tries to read the handshake of the remote peer.

Returns:
true if the handshake is correctly read and returns false if the handshake is not yet completely buffered by the Transport or it was incorrect.
Todo:
if handshake is incorrect, go to CorrupredSession state and disconnect the transports?

Definition at line 146 of file Session.cpp.

void Session::readPacket  )  [private]
 

Definition at line 190 of file Session.cpp.

void Session::readyRead  )  [private]
 

Definition at line 97 of file Session.cpp.

void Session::readyWrite  )  [private]
 

Definition at line 127 of file Session.cpp.

void Session::waitRequest  ) 
 

Definition at line 73 of file Session.cpp.

void Session::writeHandshake  )  [private]
 

Writes our handshake to the transport.

Definition at line 170 of file Session.cpp.

void Session::writePacket  )  [private]
 

Definition at line 205 of file Session.cpp.


Member Data Documentation

FileId Protocols::BitTorrent::Transfers::Session::fileId [private]
 

Definition at line 86 of file Session.h.

PeerInfo Protocols::BitTorrent::Transfers::Session::localPeerInfo [private]
 

Definition at line 84 of file Session.h.

PeerInfo Protocols::BitTorrent::Transfers::Session::remotePeerInfo [private]
 

Definition at line 85 of file Session.h.

State Protocols::BitTorrent::Transfers::Session::state [private]
 

Definition at line 87 of file Session.h.

SessionStatus& Protocols::BitTorrent::Transfers::Session::status [private]
 

Definition at line 83 of file Session.h.

Transport& Protocols::BitTorrent::Transfers::Session::transport [private]
 

Definition at line 82 of file Session.h.


The documentation for this class was generated from the following files: