Made the client disconnection more verbose. And some minor fixes.
[quassel.git] / src / core / coresession.cpp
index d71144f..4003783 100644 (file)
@@ -49,7 +49,8 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent)
 {
 
   SignalProxy *p = signalProxy();
-
+  connect(p, SIGNAL(peerRemoved(QIODevice *)), this, SLOT(removeClient(QIODevice *)));
+  
   //p->attachSlot(SIGNAL(disconnectFromNetwork(NetworkId)), this, SLOT(disconnectFromNetwork(NetworkId))); // FIXME
   p->attachSlot(SIGNAL(sendInput(BufferInfo, QString)), this, SLOT(msgFromClient(BufferInfo, QString)));
   p->attachSignal(this, SIGNAL(displayMsg(Message)));
@@ -224,6 +225,17 @@ void CoreSession::addClient(QObject *dev) { // this is QObject* so we can use it
   }
 }
 
+void CoreSession::removeClient(QIODevice *iodev) {
+  // no checks for validity check - privateslot...
+  QTcpSocket *socket = qobject_cast<QTcpSocket *>(iodev);
+  if(socket)
+    qDebug() << qPrintable(tr("Client %1 disconnected (UserId: %2).").arg(socket->peerAddress().toString()).arg(user().toInt()));
+  else
+    qDebug() << "Local client disconnedted.";
+  disconnect(socket, 0, this, 0);
+  socket->deleteLater();
+}
+
 SignalProxy *CoreSession::signalProxy() const {
   return _signalProxy;
 }