#include <GenericSession.h> [code]
Inherits Protocols::Generics::Session, and Protocols::Generics::TransportStatus.
Inherited by Protocols::BitTorrent::Transfers::PacketSession.
Inheritance diagram for Protocols::Generics::GenericSession:


GenericSession implements the Session interface. It is a generic component that provides a generic solution for Data exchange over an already connected Transport.
A DataSerializer helper object passed by reference to the ctor is used to read and write packets from and to Transport. DataSerializer will know how to convert C++ representation of protocol data from and to a raw bytes representation,
A DataQueue helper object passed by reference to the ctor is used to queue outgoing Data objects (protocol data) if the Transport's buffer gets full. Different DataQueue objects could implement different queueing policies and even flow control algorithms.
A SessionStatus object passed by reference to the ctor will get different notifications from the GenericSession object.
class ConcreteSession : public GenericSession, public SessionStatus { public: ConcreteSession (Transport &t) : GenericSession (t, serializer, queue, this), serializer (...), queue (...) {} // SessionStatus interface implementation: ... private: ConcreteSerializer serializer; ConcreteQueue queue; };
Multiple inheritance (no matter whether only from abstract base classes) results in different addresses when the same object is cast (statically and dynamically) to the abstract base classes.
Definition at line 99 of file GenericSession.h.
Public Member Functions | |
| GenericSession (Transport *, DataSerializer *, DataQueue *, SessionStatus *) | |
| Constructs a GenericSession object. | |
| ~GenericSession () | |
| Destroys a GenericSession object. | |
| void | open () |
| Opens the session and start reading buffered data from Transport. | |
| void | send (const Data &) |
| Sends a serialized Data object over the underlying Transport. | |
| void | close () |
| Closes the session by flusing the queue and disconnecting the Transport. | |
| void | abort () |
| Aborts the session by stopping data exchange and aborting the Transport. | |
| void | transportConnected (Transport *) |
| Implements part of the TransportSession interface. | |
| void | transportReadyRead (Transport *) |
| Tries to read any Data objects buffered in Transport. | |
| void | transportReadyWrite (Transport *) |
| Tries to write to Transport as much queued Data objects as possible. | |
| void | transportDisconnected (Transport *) |
| Handles the TransportStatus notification and closes the session. | |
Private Types | |
| enum | State { Closed, Opened, Closing } |
Private Member Functions | |
| CALITKO_TESTABLE | GenericSession (const GenericSession &) |
| GenericSession & | operator= (const GenericSession &) |
Private Attributes | |
| Transport * | transport |
| DataSerializer * | dataSerializer |
| DataQueue * | dataQueue |
| SessionStatus * | status |
| State | state |
|
|
Definition at line 125 of file GenericSession.h. |
|
|
|
|
||||||||||||||||||||
|
Constructs a GenericSession object.
Definition at line 43 of file GenericSession.cpp. |
|
|
Destroys a GenericSession object.
Definition at line 58 of file GenericSession.cpp. |
|
|
Aborts the session by stopping data exchange and aborting the Transport.
Implements Protocols::Generics::Session. Definition at line 100 of file GenericSession.cpp. |
|
|
Closes the session by flusing the queue and disconnecting the Transport. The session enters the Closing State - it will not allow any more Data to be sent using send(). It will wait that all Data already queued is written and will then disconnect the transport. Implements Protocols::Generics::Session. Definition at line 115 of file GenericSession.cpp. |
|
|
Opens the session and start reading buffered data from Transport. The session is opened first (internal state is changed) and then it will be attempted to read any Data that has already been buffered in the underlying transport-> Implements Protocols::Generics::Session. Definition at line 68 of file GenericSession.cpp. |
|
|
|
|
|
Sends a serialized Data object over the underlying Transport.
Implements Protocols::Generics::Session. Definition at line 86 of file GenericSession.cpp. |
|
|
Implements part of the TransportSession interface.
Implements Protocols::Generics::TransportStatus. Definition at line 131 of file GenericSession.cpp. |
|
|
Handles the TransportStatus notification and closes the session.
Implements Protocols::Generics::TransportStatus. Definition at line 161 of file GenericSession.cpp. |
|
|
Tries to read any Data objects buffered in Transport.
Implements Protocols::Generics::TransportStatus. Definition at line 137 of file GenericSession.cpp. |
|
|
Tries to write to Transport as much queued Data objects as possible.
Implements Protocols::Generics::TransportStatus. Definition at line 148 of file GenericSession.cpp. |
|
|
Definition at line 134 of file GenericSession.h. |
|
|
Definition at line 133 of file GenericSession.h. |
|
|
Definition at line 136 of file GenericSession.h. |
|
|
Reimplemented in Protocols::BitTorrent::Transfers::PacketSession. Definition at line 135 of file GenericSession.h. |
|
|
Reimplemented in Protocols::BitTorrent::Transfers::PacketSession. Definition at line 132 of file GenericSession.h. |