22 lines
566 B
C++
22 lines
566 B
C++
#pragma once
|
|
|
|
#include "logic/reactor.h"
|
|
#include "messages.pb.h"
|
|
#include "services.grpc.pb.h"
|
|
#include <grpcpp/server_context.h>
|
|
#include <grpcpp/support/server_callback.h>
|
|
#include <map>
|
|
|
|
class Service : public chat::Chat::CallbackService {
|
|
public:
|
|
~Service();
|
|
grpc::ServerBidiReactor<chat::chatMsg, chat::chatMsg> *
|
|
sendMsg(grpc::CallbackServerContext *context) override;
|
|
void sendToAll(chat::chatMsg &msg);
|
|
|
|
private:
|
|
std::map<std::string, ChatReactor *> m_clients;
|
|
absl::Mutex m_mu;
|
|
std::vector<chat::chatMsg> m_messages ABSL_GUARDED_BY(m_mu);
|
|
};
|