diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2008-09-13 03:59:58 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2008-09-13 03:59:58 +0200 |
commit | 7e87778a02f3d37865c10051a3f14038bbbcbaef (patch) | |
tree | b1853c2e1d94d0d8d7d87b3e5db73fa618019b29 /src/Net/Connection.h | |
parent | 920c506d477bd7f357e05590e8cdedf8e5e8a1b8 (diff) | |
download | mad-7e87778a02f3d37865c10051a3f14038bbbcbaef.tar mad-7e87778a02f3d37865c10051a3f14038bbbcbaef.zip |
Benutze weniger Inline-Funktionen
Diffstat (limited to 'src/Net/Connection.h')
-rw-r--r-- | src/Net/Connection.h | 58 |
1 files changed, 6 insertions, 52 deletions
diff --git a/src/Net/Connection.h b/src/Net/Connection.h index 0f012f1..58e7291 100644 --- a/src/Net/Connection.h +++ b/src/Net/Connection.h @@ -72,14 +72,7 @@ class Connection { return (transR.length == transR.transmitted); } - void bye() { - if(state != DISCONNECT) - return; - - state = BYE; - - doBye(); - } + void bye(); // Prevent shallow copy Connection(const Connection &o); @@ -104,28 +97,14 @@ class Connection { IPAddress *peer; - void handshake() { - if(isConnected()) - return; - - state = HANDSHAKE; - - doHandshake(); - } + void handshake(); virtual void connectionHeader() = 0; bool rawReceive(unsigned long length, const sigc::slot<void,const void*,unsigned long> ¬ify); bool rawSend(const uint8_t *data, unsigned long length); - bool enterReceiveLoop() { - if(!isConnected() || isDisconnecting()) - return false; - - state = PACKET_HEADER; - - return rawReceive(sizeof(Packet::Data), sigc::mem_fun(this, &Connection::packetHeaderReceiveHandler)); - } + bool enterReceiveLoop(); public: Connection() : state(DISCONNECTED), authenticated(false), peer(0) { @@ -135,20 +114,7 @@ class Connection { gnutls_certificate_allocate_credentials(&x509_cred); } - virtual ~Connection() { - if(isConnected()) - doDisconnect(); - - if(transR.data) - delete [] transR.data; - - while(!sendQueueEmpty()) { - delete [] transS.front().data; - transS.pop(); - } - - gnutls_certificate_free_credentials(x509_cred); - } + virtual ~Connection(); bool isConnected() const {return (state != DISCONNECTED);} bool isConnecting() const { @@ -174,23 +140,11 @@ class Connection { const IPAddress* getPeer() {return peer;} int getSocket() const {return sock;} - void disconnect() { - if(isConnected() && !isDisconnecting()) { - state = DISCONNECT; - - if(sendQueueEmpty()) - bye(); - } - } + void disconnect(); struct pollfd getPollfd() const; - bool send(const Packet &packet) { - if(!isConnected() || isConnecting() || isDisconnecting()) - return false; - - return rawSend((const uint8_t*)packet.getRawData(), packet.getRawDataLength()); - } + bool send(const Packet &packet); void sendReceive(short events = POLLIN|POLLOUT); |