mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
use HeaderDeliminatedHandler for NodePlugin while NewLineDeliminated for everything else
This commit is contained in:
parent
692eb13011
commit
2882d18863
4 changed files with 25 additions and 8 deletions
|
|
@ -14,5 +14,7 @@ namespace Flow.Launcher.Core.Plugin
|
|||
{
|
||||
StartInfo = new ProcessStartInfo { FileName = filename };
|
||||
}
|
||||
|
||||
protected override MessageHandlerType MessageHandler { get; } = MessageHandlerType.NewLineDelimited;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,12 +86,26 @@ namespace Flow.Launcher.Core.Plugin
|
|||
|
||||
public event ResultUpdatedEventHandler ResultsUpdated;
|
||||
|
||||
protected enum MessageHandlerType
|
||||
{
|
||||
HeaderDelimited,
|
||||
LengthHeaderDelimited,
|
||||
NewLineDelimited
|
||||
}
|
||||
|
||||
protected abstract MessageHandlerType MessageHandler { get; }
|
||||
|
||||
|
||||
private void SetupJsonRPC()
|
||||
{
|
||||
var formatter = new SystemTextJsonFormatter { JsonSerializerOptions = RequestSerializeOption };
|
||||
var handler = new NewLineDelimitedMessageHandler(ClientPipe,
|
||||
formatter);
|
||||
IJsonRpcMessageHandler handler = MessageHandler switch
|
||||
{
|
||||
MessageHandlerType.HeaderDelimited => new HeaderDelimitedMessageHandler(ClientPipe, formatter),
|
||||
MessageHandlerType.LengthHeaderDelimited => new LengthHeaderMessageHandler(ClientPipe, formatter),
|
||||
MessageHandlerType.NewLineDelimited => new NewLineDelimitedMessageHandler(ClientPipe, formatter),
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
|
||||
RPC = new JsonRpc(handler, new JsonRPCPublicAPI(Context.API));
|
||||
|
||||
|
|
|
|||
|
|
@ -24,5 +24,7 @@ namespace Flow.Launcher.Core.Plugin
|
|||
StartInfo.ArgumentList.Add(context.CurrentPluginMetadata.ExecuteFilePath);
|
||||
await base.InitAsync(context);
|
||||
}
|
||||
|
||||
protected override MessageHandlerType MessageHandler { get; } = MessageHandlerType.HeaderDelimited;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,13 +19,10 @@ namespace Flow.Launcher.Core.Plugin
|
|||
internal sealed class PythonPluginV2 : ProcessStreamPluginV2
|
||||
{
|
||||
protected override ProcessStartInfo StartInfo { get; set; }
|
||||
|
||||
|
||||
public PythonPluginV2(string filename)
|
||||
{
|
||||
StartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = filename,
|
||||
};
|
||||
StartInfo = new ProcessStartInfo { FileName = filename, };
|
||||
|
||||
var path = Path.Combine(Constant.ProgramDirectory, JsonRpc);
|
||||
StartInfo.EnvironmentVariables["PYTHONPATH"] = path;
|
||||
|
|
@ -33,11 +30,13 @@ namespace Flow.Launcher.Core.Plugin
|
|||
//Add -B flag to tell python don't write .py[co] files. Because .pyc contains location infos which will prevent python portable
|
||||
StartInfo.ArgumentList.Add("-B");
|
||||
}
|
||||
|
||||
|
||||
public override async Task InitAsync(PluginInitContext context)
|
||||
{
|
||||
StartInfo.ArgumentList.Add(context.CurrentPluginMetadata.ExecuteFilePath);
|
||||
await base.InitAsync(context);
|
||||
}
|
||||
|
||||
protected override MessageHandlerType MessageHandler { get; } = MessageHandlerType.NewLineDelimited;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue