Skip to content

Commit

Permalink
💾 Feat: The first time that dashboard invoke plugin function throw ne…
Browse files Browse the repository at this point in the history
…twork connection.
  • Loading branch information
Dynesshely committed Feb 25, 2024
1 parent 069443d commit eefe60f
Show file tree
Hide file tree
Showing 6 changed files with 379 additions and 114 deletions.
4 changes: 2 additions & 2 deletions KitX Dashboard/Converters/PluginInfoConverters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ public class PluginInfoSelectedConverter : IMultiValueConverter
{
public object? Convert(IList<object?> values, Type targetType, object? parameter, CultureInfo culture)
{
if (values.Count != 2) return false;
if (values.Count != 3) return false;

if (values[0] is string id1)
if (values[1] is string id2)
return id1.Equals(id2);
return id1.Equals(id2) && (bool)values[2]!;

return false;
}
Expand Down
2 changes: 1 addition & 1 deletion KitX Dashboard/Network/PluginsNetwork/PluginConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ private void SendWorkingDetail()
}
}

private async void Request(Request request)
internal async void Request(Request request)
{
await _connection!.Send(JsonSerializer.Serialize(request, serializerOptions));
}
Expand Down
13 changes: 13 additions & 0 deletions KitX Dashboard/Network/PluginsNetwork/PluginsServer.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Fleck;
using KitX.Dashboard.Configuration;
using KitX.Dashboard.Services;
using KitX.Shared.Plugin;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Linq;
Expand Down Expand Up @@ -50,6 +51,18 @@ public PluginsServer Run()
return this;
}

public PluginConnector? FindConnector(PluginInfo info)
{
var query = PluginConnectors.Where(
x => x.PluginInfo.HasValue && x.PluginInfo.Value.Equals(info)
);

if (query.Any())
return query.First();
else
return null;
}

public async Task<PluginsServer> Close()
{
await Task.Run(() =>
Expand Down
Loading

0 comments on commit eefe60f

Please sign in to comment.