diff options
| author | Stefan Boberg <[email protected]> | 2026-04-23 18:16:57 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2026-04-23 18:16:57 +0200 |
| commit | 0232b991cd7d8e3a2114ea30e4591dd3e7b65c36 (patch) | |
| tree | 94730e7594fd09ae1fa820391ce311f6daf13905 /src/zen/zenserviceclient.cpp | |
| parent | Fix forward declaration order for s_GotSigWinch and SigWinchHandler (diff) | |
| parent | trace: declare Region event name fields as AnsiString (#1012) (diff) | |
| download | archived-zen-sb/zen-help.tar.xz archived-zen-sb/zen-help.zip | |
Merge branch 'main' into sb/zen-helpsb/zen-help
- Combine HelpCommand (this branch) with HistoryCommand (main) in zen CLI dispatcher
- Keep filter-aware TuiPickOne rewrite; adopt main's ASCII arrow glyphs in doc comment
Diffstat (limited to 'src/zen/zenserviceclient.cpp')
| -rw-r--r-- | src/zen/zenserviceclient.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/zen/zenserviceclient.cpp b/src/zen/zenserviceclient.cpp new file mode 100644 index 000000000..87d0a6c26 --- /dev/null +++ b/src/zen/zenserviceclient.cpp @@ -0,0 +1,55 @@ +// Copyright Epic Games, Inc. All Rights Reserved. + +#include "zenserviceclient.h" + +#include "zen.h" + +#include <zencore/logging.h> +#include <zencore/logging/broadcastsink.h> +#include <zencore/session.h> +#include <zenutil/logging.h> + +namespace zen { + +ZenServiceClient::ZenServiceClient(Options Opts) +: m_HostSpec(ZenCmdBase::ResolveTargetHostSpec(Opts.HostSpec)) +, m_Http(ZenCmdBase::CreateHttpClient(m_HostSpec, Opts.HttpSettings)) +{ + if (m_HostSpec.empty()) + { + throw OptionParseException("Unable to resolve server specification", {}); + } + + SessionsServiceClient::Options SessionOpts{ + .TargetUrl = m_HostSpec, + .AppName = "zen", + .Mode = std::move(Opts.CommandName), + .SessionId = GetSessionId(), + }; + + // For unix socket connections, forward the socket path to the sessions client + if (ZenCmdBase::IsUnixSocketSpec(m_HostSpec)) + { + SessionOpts.TargetUrl = "http://localhost"; + SessionOpts.ClientSettings.UnixSocketPath = m_HostSpec.substr(7); // strip "unix://" + } + + m_Sessions = std::make_unique<SessionsServiceClient>(std::move(SessionOpts)); + m_Sessions->Announce(); + + m_LogSink = m_Sessions->CreateLogSink(); + GetDefaultBroadcastSink()->AddSink(m_LogSink); +} + +ZenServiceClient::~ZenServiceClient() +{ + if (m_LogSink) + { + if (Ref<logging::BroadcastSink> Broadcast = GetDefaultBroadcastSink()) + { + Broadcast->RemoveSink(m_LogSink); + } + } +} + +} // namespace zen |