Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
ServerConnection.h
Go to the documentation of this file.
1#pragma once
2#include <QIODevice>
8
9namespace sf
10{
11
16 : public QObject
17 , protected InformationTypes
18{
19 public:
30
34 explicit ServerConnection(QIODevice* ioDevice, QObject* parent = nullptr);
35
37
43 bool process();
44
45 void setState(EState state);
46
51
52 private:
53 ThreadRelay _relay;
54
55 VariableCollector* _varCollector;
56
57 int fromMain(int v1);
58
59 bool sendPingPong(int counter = -1);
60
61 // Holds the IO device reference.
62 QIODevice* _ioDevice;
63 // Holds the current state of the connection.
64 EState _curState;
65 // Holds the previous state of the connection.
66 EState _prevState;
67 //
68 InformationPacket::Header _headerRead;
69 DynamicBuffer _bufferRead;
70 DynamicBuffer _bufferWrite;
71};
72
73}// namespace sf
Base class for all generic information objects to be able to put them in a typed list together.
Definition InformationBase.h:25
Class handling the connection exchanging data using a QIODevice.
Definition ServerConnection.h:18
void setState(EState state)
EState
Definition ServerConnection.h:21
@ sPayloadRead
Definition ServerConnection.h:25
@ sPayloadProcess
Definition ServerConnection.h:26
@ sBufferWrite
Definition ServerConnection.h:27
@ sHeaderRead
Definition ServerConnection.h:24
@ sError
Definition ServerConnection.h:22
@ sNone
Definition ServerConnection.h:23
@ sWaitForRead
Definition ServerConnection.h:28
ServerConnection(QIODevice *ioDevice, QObject *parent=nullptr)
Constructor for passing a socket descriptor.
void relayThread()
Allows this instance to do main thread handling.
bool process()
Non-blocking method which processes data incoming and outgoing data from the IO device.
~ServerConnection() override
Provides a way to stop executing a thread until the main thread enables the thread again.
Definition ThreadRelay.h:37
Definition VariableCollector.h:14
Definition Application.h:10
Byte aligned packet header.
Definition InformationPacket.h:65