diff options
Diffstat (limited to 'src/Net/Connection.h')
-rw-r--r-- | src/Net/Connection.h | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/src/Net/Connection.h b/src/Net/Connection.h index a3670b0..01926e1 100644 --- a/src/Net/Connection.h +++ b/src/Net/Connection.h @@ -62,12 +62,23 @@ class Connection { void doReceive(); void doSend(); + void doBye(); + void doDisconnect(); bool receiveComplete() const { return (transR.length == transR.transmitted); } + void bye() { + if(state != DISCONNECT) + return; + + state = BYE; + + doBye(); + } + // Prevent shallow copy Connection(const Connection &o); Connection& operator=(const Connection &o); @@ -162,26 +173,7 @@ class Connection { return rawSend(reinterpret_cast<const unsigned char*>(packet.getRawData()), packet.getRawDataLength()); } - void sendReceive(short events = POLLIN|POLLOUT) { - if(events & POLLHUP || events & POLLERR) { - doDisconnect(); - return; - } - - if(state == HANDSHAKE) { - doHandshake(); - return; - } - - if(events & POLLIN) - doReceive(); - - if(events & POLLOUT) - doSend(); - - if(state == DISCONNECT && sendQueueEmpty()) - doDisconnect(); - } + void sendReceive(short events = POLLIN|POLLOUT); bool sendQueueEmpty() const {return transS.empty();} |