mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 18:26:39 +02:00
38 lines
1.1 KiB
C++
38 lines
1.1 KiB
C++
|
|
#include "pch.h"
|
||
|
|
#include "TwoWayPipeMessageIPCManaged.h"
|
||
|
|
#include "TwoWayPipeMessageIPCManaged.g.cpp"
|
||
|
|
#include "two_way_pipe_message_ipc_impl.h"
|
||
|
|
#include <functional>
|
||
|
|
|
||
|
|
namespace winrt::PowerToys::Interop::implementation
|
||
|
|
{
|
||
|
|
TwoWayPipeMessageIPCManaged::TwoWayPipeMessageIPCManaged(hstring const& inputPipeName, hstring const& outputPipeName, winrt::PowerToys::Interop::TwoWayPipeIPCReadCallback const& _callback)
|
||
|
|
{
|
||
|
|
this->_callback = _callback;
|
||
|
|
if (_callback != nullptr)
|
||
|
|
{
|
||
|
|
_internalReadCallback = [this](const std::wstring& msg) {
|
||
|
|
this->_callback(msg);
|
||
|
|
};
|
||
|
|
}
|
||
|
|
_pipe = new TwoWayPipeMessageIPC(std::wstring{ inputPipeName }, std::wstring{ outputPipeName }, _internalReadCallback);
|
||
|
|
}
|
||
|
|
|
||
|
|
void TwoWayPipeMessageIPCManaged::Send(hstring const& msg)
|
||
|
|
{
|
||
|
|
_pipe->send(std::wstring{ msg });
|
||
|
|
}
|
||
|
|
void TwoWayPipeMessageIPCManaged::Start()
|
||
|
|
{
|
||
|
|
_pipe->start(nullptr);
|
||
|
|
}
|
||
|
|
void TwoWayPipeMessageIPCManaged::End()
|
||
|
|
{
|
||
|
|
_pipe->end();
|
||
|
|
}
|
||
|
|
void TwoWayPipeMessageIPCManaged::Close()
|
||
|
|
{
|
||
|
|
delete _pipe;
|
||
|
|
}
|
||
|
|
}
|