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 };
|
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;
|
public event ResultUpdatedEventHandler ResultsUpdated;
|
||||||
|
|
||||||
|
protected enum MessageHandlerType
|
||||||
|
{
|
||||||
|
HeaderDelimited,
|
||||||
|
LengthHeaderDelimited,
|
||||||
|
NewLineDelimited
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract MessageHandlerType MessageHandler { get; }
|
||||||
|
|
||||||
|
|
||||||
private void SetupJsonRPC()
|
private void SetupJsonRPC()
|
||||||
{
|
{
|
||||||
var formatter = new SystemTextJsonFormatter { JsonSerializerOptions = RequestSerializeOption };
|
var formatter = new SystemTextJsonFormatter { JsonSerializerOptions = RequestSerializeOption };
|
||||||
var handler = new NewLineDelimitedMessageHandler(ClientPipe,
|
IJsonRpcMessageHandler handler = MessageHandler switch
|
||||||
formatter);
|
{
|
||||||
|
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));
|
RPC = new JsonRpc(handler, new JsonRPCPublicAPI(Context.API));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,5 +24,7 @@ namespace Flow.Launcher.Core.Plugin
|
||||||
StartInfo.ArgumentList.Add(context.CurrentPluginMetadata.ExecuteFilePath);
|
StartInfo.ArgumentList.Add(context.CurrentPluginMetadata.ExecuteFilePath);
|
||||||
await base.InitAsync(context);
|
await base.InitAsync(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override MessageHandlerType MessageHandler { get; } = MessageHandlerType.HeaderDelimited;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,7 @@ namespace Flow.Launcher.Core.Plugin
|
||||||
|
|
||||||
public PythonPluginV2(string filename)
|
public PythonPluginV2(string filename)
|
||||||
{
|
{
|
||||||
StartInfo = new ProcessStartInfo
|
StartInfo = new ProcessStartInfo { FileName = filename, };
|
||||||
{
|
|
||||||
FileName = filename,
|
|
||||||
};
|
|
||||||
|
|
||||||
var path = Path.Combine(Constant.ProgramDirectory, JsonRpc);
|
var path = Path.Combine(Constant.ProgramDirectory, JsonRpc);
|
||||||
StartInfo.EnvironmentVariables["PYTHONPATH"] = path;
|
StartInfo.EnvironmentVariables["PYTHONPATH"] = path;
|
||||||
|
|
@ -39,5 +36,7 @@ namespace Flow.Launcher.Core.Plugin
|
||||||
StartInfo.ArgumentList.Add(context.CurrentPluginMetadata.ExecuteFilePath);
|
StartInfo.ArgumentList.Add(context.CurrentPluginMetadata.ExecuteFilePath);
|
||||||
await base.InitAsync(context);
|
await base.InitAsync(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override MessageHandlerType MessageHandler { get; } = MessageHandlerType.NewLineDelimited;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue