mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-08-08 00:17:49 +00:00
Added new projects of new RPC core: MyClient and MtServivce
This commit is contained in:
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include "MtMessage.h"
|
||||
|
||||
typedef std::function<void(const MtResponse&)> TaskCallback;
|
||||
|
||||
class CommandTask
|
||||
{
|
||||
public:
|
||||
CommandTask(std::unique_ptr<MtCommand> command, TaskCallback callback)
|
||||
: command_(std::move(command))
|
||||
, callback_(std::move(callback))
|
||||
{}
|
||||
|
||||
MtCommand& getCommand() const { return *command_; }
|
||||
|
||||
void ProcessResponse(int handle, const std::string& payload)
|
||||
{
|
||||
MtResponse respone(handle, command_->getCommandId(), payload);
|
||||
callback_(respone);
|
||||
}
|
||||
|
||||
private:
|
||||
std::unique_ptr<MtCommand> command_;
|
||||
TaskCallback callback_;
|
||||
};
|
||||
Reference in New Issue
Block a user