PacketSession.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef GNUTELLA__PACKET_PROCESSING__PACKET_SESSION_H
00024 #define GNUTELLA__PACKET_PROCESSING__PACKET_SESSION_H
00025
00026 #include "Gnutella/Packets/Namespace.h"
00027 #include "Protocols/Transports/Connection.h"
00028 #include "Gnutella/NodeInfo.h"
00029
00030 namespace Gnutella { namespace PacketProcessing { namespace QueryRouting { class QueryRoutingTable; }}}
00031
00032
00033 namespace Gnutella {
00034 namespace PacketProcessing {
00036
00037 using Protocols::Transports::Connection;
00038 using Gnutella::NodeInfo;
00039 using Gnutella::Packets::Packet;
00040 using Gnutella::PacketProcessing::QueryRouting::QueryRoutingTable;
00041
00042 class PacketSessionPrivate;
00043
00044
00045 class PacketSession : public QObject
00046 {
00047 Q_OBJECT
00048 REFERENCE_OBJECT (PacketSession)
00049
00050 public:
00052
00056 enum CloseCode
00057 {
00058 CloseNoBye = 0,
00059 ExittingNormally = 200,
00060 ExplicitClose = 201,
00061 TooBigPackets = 400,
00062 TooManyDuplicates = 401,
00063 BadQueries = 402,
00064 TooHighTtlHops = 403,
00065 ManyUnknownPackets = 404,
00066 InactivityTimeout = 405,
00067 NoTtl1PingReply = 406,
00068 NotSharingEnough = 407,
00069 InternalError = 500,
00070 ProtocolDesync = 501,
00071 SendQueueFull = 502
00072 };
00073
00074 PacketSession (Connection *, const NodeInfo &);
00075 ~PacketSession();
00076
00077 NodeInfo nodeInfo() const;
00078 const QueryRoutingTable & queryRoutingTable() const;
00079
00080 void closeSession (CloseCode);
00081
00082 void sendPacket (const Packet &packet);
00083 void sendQrt (const QueryRoutingTable &);
00084
00085 int readTimeout() const;
00086 void setReadTimeout (int);
00087
00088 void deleteLater();
00089
00090 signals:
00091 void packetRead (Packet &, PacketSession *);
00092 void qrtRead (PacketSession *);
00093 void sessionClosed (PacketSession *);
00094
00095 private slots:
00096 void readTimeout();
00097 void connectionClosed();
00098 void packetRead();
00099 void packetWritten();
00100 void qrtRead();
00101 void readError();
00102
00103
00104 private:
00105 PacketSessionPrivate *p;
00106 };
00107
00108
00109 }
00110 }
00112
00113 #endif // GNUTELLA__PACKET_PROCESSING__PACKET_SESSION_H