//
// Created by zx on 22-12-22.
//

#ifndef SOCKETIO__SERVERTCPSTATU_H_
#define SOCKETIO__SERVERTCPSTATU_H_
#include "TCPServer.h"

typedef void (*RecvCallback)(std::string,int,std::string);

class ServerTcpStatu :public TCPServer
{
 public:
    ServerTcpStatu();
    bool Bind(int port);
    void SetRecvCallback(RecvCallback callback);
    void Publish(std::string data);
 protected:
    void accept();
    void recv();

 protected:
    bool exit_=false;
    std::thread* thread_accept= nullptr;
    std::thread* thread_recv= nullptr;
    RecvCallback recv_callback_= nullptr;
    std::mutex mutex_;
};


#endif //SOCKETIO__SERVERTCPSTATU_H_
