-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathClientObject.h
68 lines (51 loc) · 1.74 KB
/
ClientObject.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef CLIENTOBJECT_H
#define CLIENTOBJECT_H
#include <thread>
#include <atomic>
#include <iostream>
#include <boost/lockfree/spsc_queue.hpp>
#include "global.h"
#include "Tuner.h"
#include "SignalDecoder.h"
#include "NarrowFFT.h"
class ClientObject {
public:
// Constructor that starts the client thread
ClientObject(int clientId, const std::string& clientIP);
// Destructor to clean up the thread
~ClientObject();
// Function to stop the client's processing
void stop();
// Function to enqueue client info (used by ClientManager)
bool enqueueInfoForCLient(const ClientInfo& clientInfo);
// Get the client's IP address
std::string getClientIP() const;
// check the password
bool checkPW();
std::string username = "";
std::string password = "";
private:
// The thread that does the processing for the client
std::thread clientThread;
// Internal function that runs in the thread
void processClient();
void setFrequency(ClientInfo clientInfo);
void setBand(ClientInfo clientInfo);
void setMode(ClientInfo clientInfo);
void setFilter(ClientInfo clientInfo);
void decodeSamples(ClientInfo clientInfo);
void userPW(ClientInfo clientInfo);
// Flag to stop the thread
int clientId;
std::atomic<bool> keepRunning;
std::string clientIP;
// Queue for incoming messages (from ClientManager)
boost::lockfree::spsc_queue<ClientInfo, boost::lockfree::capacity<100>> clientObjectInputQueue;
// Tuner: shifts the wanted frequency into the baseband
Tuner tuner;
// SignalDecoder: demodulates and returns audio
SignalDecoder signaldecoder;
// narrow band FFT processor
NarrowFFTProcessor narrowFFT;
};
#endif // CLIENTOBJECT_H