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
|
// Copyright (c) 2015-2015 Josh Blum
// SPDX-License-Identifier: BSL-1.0
#pragma once
#include <csignal> //sig_atomic_t
#include <string>
#include <thread>
#include <map>
class SoapyRPCSocket;
//! Client handler data
struct SoapyServerThreadData
{
SoapyServerThreadData(void);
~SoapyServerThreadData(void);
void handlerLoop(void);
sig_atomic_t done;
std::thread *thread;
SoapyRPCSocket *client;
std::string uuid;
};
/*!
* The server listener class accepts clients and spawns threads.
*/
class SoapyServerListener
{
public:
SoapyServerListener(SoapyRPCSocket &sock, const std::string &uuid);
~SoapyServerListener(void);
void handleOnce(void);
private:
SoapyRPCSocket &_sock;
const std::string _uuid;
size_t _handlerId;
std::map<size_t, SoapyServerThreadData> _handlers;
};
|