52 lines
1.1 KiB
C++
52 lines
1.1 KiB
C++
#ifndef CETHERNETNETWORKSERVER_H
|
|
#define CETHERNETNETWORKSERVER_H
|
|
|
|
|
|
#include <QObject>
|
|
#include "NetworkProtocol.h"
|
|
#include <QTcpServer>
|
|
#include <QTcpSocket>
|
|
#include <QList>
|
|
#include <NetworkDevice.h>
|
|
|
|
class CEthernetDeviceConnection
|
|
{
|
|
public:
|
|
|
|
QTcpSocket *mConnectionSocket;
|
|
CNetworkDevice *mConnectedDevice;
|
|
|
|
};
|
|
|
|
class CEthernetNetworkServer : public QObject, CNetworkProtocol
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
CEthernetNetworkServer();
|
|
|
|
QTcpServer *mEthernetNetworkServer;
|
|
|
|
|
|
|
|
QList<CNetworkDevice*> mNetworkDevices;
|
|
QList<CEthernetDeviceConnection*> mEthernetDeviceConnections;
|
|
|
|
|
|
|
|
virtual int NewFrameReceived(QByteArray Frame);
|
|
bool IsDeviceRegistered(int DeviceID);
|
|
int RegisterNewDevice(CNetworkDevice* Device);
|
|
|
|
private:
|
|
int FindConnection(CEthernetDeviceConnection* Connection);
|
|
CEthernetDeviceConnection *FindConnection(QTcpSocket* socket);
|
|
int CloseConnection(CEthernetDeviceConnection *Connection);
|
|
|
|
public slots:
|
|
void EthernetNetworkServerConnected();
|
|
void DeviceSocketDataAvail();
|
|
void DeviceSocketDisconnected();
|
|
};
|
|
|
|
#endif // CETHERNETNETWORKSERVER_H
|