mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-07-09 18:27:36 +00:00
Compare commits
2 Commits
feature/se
...
feature/so
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8151a2fad | ||
|
|
c1bf6d9423 |
@@ -1,3 +1,9 @@
|
|||||||
|
## 0.5.0
|
||||||
|
|
||||||
|
## ElectronNET.Core
|
||||||
|
|
||||||
|
- tbd
|
||||||
|
|
||||||
# 0.4.1
|
# 0.4.1
|
||||||
|
|
||||||
## ElectronNET.Core
|
## ElectronNET.Core
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ Add the Electron.NET configuration to your `.csproj` file:
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ElectronNET.Core" Version="0.4.1" />
|
<PackageReference Include="ElectronNET.Core" Version="0.5.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ namespace ElectronNET.API
|
|||||||
{
|
{
|
||||||
internal static class BridgeConnector
|
internal static class BridgeConnector
|
||||||
{
|
{
|
||||||
public static SocketIoFacade Socket
|
public static ISocketConnection Socket
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
|||||||
56
src/ElectronNET.API/Bridge/ISocketConnection.cs
Normal file
56
src/ElectronNET.API/Bridge/ISocketConnection.cs
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
namespace ElectronNET.API;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Common interface for communication facades.
|
||||||
|
/// Provides methods for bidirectional communication between .NET and Electron.
|
||||||
|
/// </summary>
|
||||||
|
internal interface ISocketConnection : IDisposable
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Raised when the bridge connection is established.
|
||||||
|
/// </summary>
|
||||||
|
event EventHandler BridgeConnected;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Raised when the bridge connection is lost.
|
||||||
|
/// </summary>
|
||||||
|
event EventHandler BridgeDisconnected;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Establishes the connection to Electron.
|
||||||
|
/// </summary>
|
||||||
|
void Connect();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Registers a persistent event handler.
|
||||||
|
/// </summary>
|
||||||
|
void On(string eventName, Action action);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Registers a persistent event handler with a typed parameter.
|
||||||
|
/// </summary>
|
||||||
|
void On<T>(string eventName, Action<T> action);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Registers a one-time event handler.
|
||||||
|
/// </summary>
|
||||||
|
void Once(string eventName, Action action);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Registers a one-time event handler with a typed parameter.
|
||||||
|
/// </summary>
|
||||||
|
void Once<T>(string eventName, Action<T> action);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes an event handler.
|
||||||
|
/// </summary>
|
||||||
|
void Off(string eventName);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends a message to Electron.
|
||||||
|
/// </summary>
|
||||||
|
Task Emit(string eventName, params object[] args);
|
||||||
|
}
|
||||||
@@ -8,13 +8,13 @@ using ElectronNET.API.Serialization;
|
|||||||
using SocketIO.Serializer.SystemTextJson;
|
using SocketIO.Serializer.SystemTextJson;
|
||||||
using SocketIO = SocketIOClient.SocketIO;
|
using SocketIO = SocketIOClient.SocketIO;
|
||||||
|
|
||||||
internal class SocketIoFacade : IDisposable
|
internal class SocketIOConnection : ISocketConnection
|
||||||
{
|
{
|
||||||
private readonly SocketIO _socket;
|
private readonly SocketIO _socket;
|
||||||
private readonly object _lockObj = new object();
|
private readonly object _lockObj = new object();
|
||||||
private bool _isDisposed;
|
private bool _isDisposed;
|
||||||
|
|
||||||
public SocketIoFacade(string uri)
|
public SocketIOConnection(string uri)
|
||||||
{
|
{
|
||||||
_socket = new SocketIO(uri);
|
_socket = new SocketIO(uri);
|
||||||
_socket.Serializer = new SystemTextJsonSerializer(ElectronJson.Options);
|
_socket.Serializer = new SystemTextJsonSerializer(ElectronJson.Options);
|
||||||
@@ -140,7 +140,7 @@ internal class SocketIoFacade : IDisposable
|
|||||||
{
|
{
|
||||||
if (this._isDisposed)
|
if (this._isDisposed)
|
||||||
{
|
{
|
||||||
throw new ObjectDisposedException(nameof(SocketIoFacade));
|
throw new ObjectDisposedException(nameof(SocketIOConnection));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
|
|
||||||
internal static Func<Task> OnAppReadyCallback { get; set; }
|
internal static Func<Task> OnAppReadyCallback { get; set; }
|
||||||
|
|
||||||
internal static SocketIoFacade GetSocket()
|
internal static ISocketConnection GetSocket()
|
||||||
{
|
{
|
||||||
return RuntimeControllerCore?.Socket;
|
return RuntimeControllerCore?.Socket;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
internal abstract SocketIoFacade Socket { get; }
|
internal abstract ISocketConnection Socket { get; }
|
||||||
|
|
||||||
internal abstract ElectronProcessBase ElectronProcess { get; }
|
internal abstract ElectronProcessBase ElectronProcess { get; }
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override SocketIoFacade Socket
|
internal override ISocketConnection Socket
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override SocketIoFacade Socket
|
internal override ISocketConnection Socket
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
{
|
{
|
||||||
private readonly int socketPort;
|
private readonly int socketPort;
|
||||||
private readonly string socketUrl;
|
private readonly string socketUrl;
|
||||||
private SocketIoFacade socket;
|
private SocketIOConnection socket;
|
||||||
|
|
||||||
public SocketBridgeService(int socketPort)
|
public SocketBridgeService(int socketPort)
|
||||||
{
|
{
|
||||||
@@ -19,11 +19,11 @@
|
|||||||
|
|
||||||
public int SocketPort => this.socketPort;
|
public int SocketPort => this.socketPort;
|
||||||
|
|
||||||
internal SocketIoFacade Socket => this.socket;
|
internal SocketIOConnection Socket => this.socket;
|
||||||
|
|
||||||
protected override Task StartCore()
|
protected override Task StartCore()
|
||||||
{
|
{
|
||||||
this.socket = new SocketIoFacade(this.socketUrl);
|
this.socket = new SocketIOConnection(this.socketUrl);
|
||||||
this.socket.BridgeConnected += this.Socket_BridgeConnected;
|
this.socket.BridgeConnected += this.Socket_BridgeConnected;
|
||||||
this.socket.BridgeDisconnected += this.Socket_BridgeDisconnected;
|
this.socket.BridgeDisconnected += this.Socket_BridgeDisconnected;
|
||||||
Task.Run(this.Connect);
|
Task.Run(this.Connect);
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
internal override SocketBridgeService SocketBridge => this.socketBridge;
|
internal override SocketBridgeService SocketBridge => this.socketBridge;
|
||||||
|
|
||||||
internal override SocketIoFacade Socket
|
internal override ISocketConnection Socket
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -70,7 +70,7 @@
|
|||||||
<ProjectReference Include="..\ElectronNET.API\ElectronNET.API.csproj" Condition="$(ElectronNetDevMode)" />
|
<ProjectReference Include="..\ElectronNET.API\ElectronNET.API.csproj" Condition="$(ElectronNetDevMode)" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ElectronNET.Core" Version="0.4.1" Condition="'$(ElectronNetDevMode)' != 'true'" />
|
<PackageReference Include="ElectronNET.Core" Version="0.5.0" Condition="'$(ElectronNetDevMode)' != 'true'" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Import Project="..\ElectronNET\build\ElectronNET.Core.targets" Condition="$(ElectronNetDevMode)" />
|
<Import Project="..\ElectronNET\build\ElectronNET.Core.targets" Condition="$(ElectronNetDevMode)" />
|
||||||
|
|||||||
@@ -27,8 +27,8 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ElectronNET.Core" Version="0.4.1" Condition="'$(ElectronNetDevMode)' != 'true'" />
|
<PackageReference Include="ElectronNET.Core" Version="0.5.0" Condition="'$(ElectronNetDevMode)' != 'true'" />
|
||||||
<PackageReference Include="ElectronNET.Core.AspNet" Version="0.4.1" Condition="'$(ElectronNetDevMode)' != 'true'" />
|
<PackageReference Include="ElectronNET.Core.AspNet" Version="0.5.0" Condition="'$(ElectronNetDevMode)' != 'true'" />
|
||||||
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="5.9.3" />
|
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="5.9.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -76,8 +76,8 @@
|
|||||||
<ProjectReference Include="..\ElectronNET.AspNet\ElectronNET.AspNet.csproj" Condition="$(ElectronNetDevMode)" />
|
<ProjectReference Include="..\ElectronNET.AspNet\ElectronNET.AspNet.csproj" Condition="$(ElectronNetDevMode)" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ElectronNET.Core" Version="0.4.1" Condition="'$(ElectronNetDevMode)' != 'true'" />
|
<PackageReference Include="ElectronNET.Core" Version="0.5.0" Condition="'$(ElectronNetDevMode)' != 'true'" />
|
||||||
<PackageReference Include="ElectronNET.Core.AspNet" Version="0.4.1" Condition="'$(ElectronNetDevMode)' != 'true'" />
|
<PackageReference Include="ElectronNET.Core.AspNet" Version="0.5.0" Condition="'$(ElectronNetDevMode)' != 'true'" />
|
||||||
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="5.9.3" />
|
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="5.9.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<Project>
|
<Project>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>0.4.1</Version>
|
<Version>0.5.0</Version>
|
||||||
<PackageNamePrefix>ElectronNET.Core</PackageNamePrefix>
|
<PackageNamePrefix>ElectronNET.Core</PackageNamePrefix>
|
||||||
<Authors>Gregor Biswanger, Florian Rappl, softworkz</Authors>
|
<Authors>Gregor Biswanger, Florian Rappl, softworkz</Authors>
|
||||||
<Product>Electron.NET</Product>
|
<Product>Electron.NET</Product>
|
||||||
|
|||||||
Reference in New Issue
Block a user