mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-14 04:57:21 +01:00
39 lines
956 B
C++
39 lines
956 B
C++
#pragma once
|
|
|
|
#include <brynet/net/detail/TCPServiceDetail.hpp>
|
|
|
|
using ConnectionOption = ConnectionOption;
|
|
class TcpService : public TcpServiceDetail,
|
|
public std::enable_shared_from_this<TcpService> {
|
|
public:
|
|
using Ptr = std::shared_ptr<TcpService>;
|
|
using FrameCallback = TcpServiceDetail::FrameCallback;
|
|
|
|
public:
|
|
static Ptr Create() {
|
|
struct make_shared_enabler : public TcpService {
|
|
};
|
|
return std::make_shared<make_shared_enabler>();
|
|
}
|
|
|
|
void startWorkerThread(size_t threadNum,
|
|
FrameCallback callback = nullptr) {
|
|
TcpServiceDetail::startWorkerThread(threadNum, callback);
|
|
}
|
|
|
|
void stopWorkerThread() {
|
|
TcpServiceDetail::stopWorkerThread();
|
|
}
|
|
|
|
bool addTcpConnection(TcpSocket::Ptr socket, ConnectionOption options) {
|
|
return TcpServiceDetail::addTcpConnection(std::move(socket), options);
|
|
}
|
|
|
|
EventLoop::Ptr getRandomEventLoop() {
|
|
return TcpServiceDetail::getRandomEventLoop();
|
|
}
|
|
|
|
private:
|
|
TcpService() = default;
|
|
};
|