# shtcpserver.h

Go to the documentation of this file.

    00001 /*
    00002  * SmartHome server: Plug-in tcpserver
    00003  *
    00004  * Copyright (C) 2010 Daniel Pisi <dan.pisi@gmail.com>
    00005  *
    00006  * This program is free software; you can redistribute it and/or modify it
    00007  * under the terms of version 2 of the GNU General Public License
    00008  * as published by the Free Software Foundation.
    00009  *
    00010  */
    00011
    00018 #ifndef SHTCPSERVER_H
    00019 #define SHTCPSERVER_H
    00020
    00021 #include <QtCore/QCoreApplication>
    00022 #include <QtPlugin>
    00023 #include <QtNetwork>
    00024 #include <QObject>
    00025 #include "shobjecthelper.h"
    00026 #include "shmessage.h"
    00027 #include "shbase.h"
    00028
    00029 // -----------------------------------------------------------------------------
    00030
    00035 class ShTcpServer : public ShObjectHelper
    00036 {
    00037     Q_OBJECT
    00038     Q_INTERFACES(ShObject)
    00039
    00040 public:
    00041     ShTcpServer() { mBufLen = 0; };
    00042     virtual ~ShTcpServer() {};
    00043     virtual bool init(QString param);
    00044     virtual void updatePins(const QList<ShPin> &pins) {};
    00045     virtual void processMessage(ShMessagePtr message);
    00046
    00047 private slots:
    00048     void newClientConnected();
    00049     void dataAvailable();
    00050
    00051 private:
    00052     void processPacket(const QString &cmd);
    00053
    00054     QTcpServer *mTcpServer;
    00055     QTcpSocket *mClientConnection;
    00056
    00057     char mBuffer[1024];
    00058     qint64 mBufLen;
    00059 };
    00060 // -----------------------------------------------------------------------------
    00061
    00062 #endif // SHTCPSERVER_H

All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends