ee9db62a0675d4935d20a265f48131af46423558
[buliscores] / buliscores-server / clientconn.cpp
1 /*
2  * Copyright (C) 2010 David Solbach <d@vidsolbach.de>
3  *
4  * This file is part of BuliScores.
5  *
6  * BuliScores is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * BiliScores is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this program; if not, write to the Free
18  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19  */
20
21 #include <QHostAddress>
22
23 #include "clientconn.h"
24
25 ClientConn::ClientConn(QTcpSocket* socket, QObject *parent) :
26     QObject(parent)
27 {
28     m_Socket = socket;
29
30     connect(socket, SIGNAL(disconnected()), this, SLOT(onSocketDisconnected()));
31 }
32
33 void ClientConn::onSocketDisconnected()
34 {
35     qDebug() << "Socket disconnected: " << m_Socket->peerAddress().toString();
36     emit disconnected();
37 }
38
39 void ClientConn::triggerUpdate()
40 {
41     if (m_Socket->isWritable()) {
42         m_Socket->write("u");
43     } else {
44         qWarning() << "Update trigger msg not send, socket state: " << m_Socket->state();
45     }
46 }