#ifndef __SERVER__GRPC__STREAM__HH_H_
#define __SERVER__GRPC__STREAM__HH_H_

#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <thread>
#include <grpcpp/grpcpp.h>
#include "def.grpc.grpc.pb.h"
#include "def.grpc.pb.h"
#include "transitData.h"

class CustomServer : public StreamServer::Service {
private:

    bool streamStatu = false;
    
public:
    CustomServer();

    ~CustomServer();

    virtual ::grpc::Status OpenStream(::grpc::ServerContext* context, const ::RequestCmd* request, ::grpc::ServerWriter< ::clouds>* writer);
    virtual ::grpc::Status CloseStream(::grpc::ServerContext* context, const ::RequestCmd* request, ::grpc::ServerWriter< ::clouds>* writer);
protected:

};


class StreamRpcServer {

private:
    grpc::ServerBuilder builder_;
    CustomServer service_;
    std::unique_ptr<grpc::Server> server_;
    std::thread *thread_;

public:
    StreamRpcServer();

    ~StreamRpcServer();

    void Listenning(std::string ip, int port);


protected:
    static void WaitThread(void *p);
};

#endif
