Add BaseIpcMessage::GetRequestId

This commit is contained in:
Fangrui Song 2018-01-19 10:00:06 -08:00
parent 5c43bd9a09
commit 8eff5e2e4f
2 changed files with 10 additions and 0 deletions

View File

@ -104,3 +104,7 @@ const char* IpcIdToString(IpcId id) {
BaseIpcMessage::BaseIpcMessage(IpcId method_id) : method_id(method_id) {} BaseIpcMessage::BaseIpcMessage(IpcId method_id) : method_id(method_id) {}
BaseIpcMessage::~BaseIpcMessage() = default; BaseIpcMessage::~BaseIpcMessage() = default;
lsRequestId BaseIpcMessage::GetRequestId() {
return std::monostate();
}

View File

@ -75,6 +75,8 @@ struct BaseIpcMessage {
BaseIpcMessage(IpcId method_id); BaseIpcMessage(IpcId method_id);
virtual ~BaseIpcMessage(); virtual ~BaseIpcMessage();
virtual lsRequestId GetRequestId();
template <typename T> template <typename T>
T* As() { T* As() {
assert(method_id == T::kIpcId); assert(method_id == T::kIpcId);
@ -87,6 +89,10 @@ struct RequestMessage : public BaseIpcMessage {
// number | string, actually no null // number | string, actually no null
lsRequestId id; lsRequestId id;
RequestMessage() : BaseIpcMessage(T::kIpcId) {} RequestMessage() : BaseIpcMessage(T::kIpcId) {}
lsRequestId GetRequestId() override {
return id;
}
}; };
// NotificationMessage does not have |id|. // NotificationMessage does not have |id|.