Skip to content

Commit 16925f4

Browse files
committed
Renamed facades
1 parent 7e7bc21 commit 16925f4

15 files changed

Lines changed: 67 additions & 61 deletions

docs/SignalR-Implementation-Summary.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Blazor Server applications where:
4141
- Implemented Socket.IO-compatible interface for API compatibility
4242

4343
### Phase 4: API Bridge Adaptation ✅
44-
- Created `SignalRFacade` implementing `IFacade` interface
44+
- Created `SignalRConnection` implementing `ISocketConnection` interface
4545
- Ensured existing Electron API classes work with SignalR
4646
- Implemented type conversion helper for SignalR's JSON deserialization
4747
- Event routing from both directions (.NET ↔ Electron)
@@ -60,8 +60,8 @@ Blazor Server applications where:
6060

6161
## Key Components
6262

63-
### 1. SignalRFacade (`src/ElectronNET.AspNet/Bridge/SignalRFacade.cs`)
64-
- Implements `IFacade` interface to match Socket.IO facade API
63+
### 1. SignalRConnection (`src/ElectronNET.AspNet/Bridge/SignalRConnection.cs`)
64+
- Implements `ISocketConnection` interface to match Socket.IO facade API
6565
- Handles bidirectional event routing using `IHubContext<ElectronHub>`
6666
- Includes `ConvertToType<T>` helper for handling SignalR's JSON deserialization quirks
6767
- Critical fix: Handles `JsonElement` and numeric type conversions (long → int)
@@ -155,8 +155,8 @@ SignalR mode uses .NET-first startup (vs. Electron-first in Socket.IO mode) beca
155155
4. **Better for Blazor Server** - Blazor is already running when Electron starts
156156
5. **Single process debugging** - Developer debugs .NET process which owns Electron
157157

158-
### Why IFacade Interface?
159-
Introducing `IFacade` allows `BridgeConnector.Socket` to return either `SocketIOFacade` or `SignalRFacade` based on startup mode, ensuring existing API code works with both transport mechanisms without modification.
158+
### Why ISocketConnection Interface?
159+
Introducing `ISocketConnection` allows `BridgeConnector.Socket` to return either `SocketIOConnection` or `SignalRConnection` based on startup mode, ensuring existing API code works with both transport mechanisms without modification.
160160

161161
### Why Keep-Alive Window?
162162
Electron quits immediately on macOS if no windows exist. The keep-alive window ensures Electron stays running during the connection and API initialization phase. It's automatically destroyed when the first real window is created.
@@ -208,7 +208,7 @@ Blazor Server already uses SignalR for component communication (`/_blazor` hub).
208208
### 3. Type Conversion Failures
209209
**Problem**: SignalR deserializes JSON numbers as `JsonElement` or `long`, causing `Once<int>` handlers to fail silently.
210210

211-
**Solution**: `SignalRFacade.ConvertToType<T>` handles JsonElement deserialization and numeric conversions.
211+
**Solution**: `SignalRConnection.ConvertToType<T>` handles JsonElement deserialization and numeric conversions.
212212

213213
### 4. Window Shutdown Not Triggering Exit
214214
**Problem**: Keep-alive window prevented `window-all-closed` event from firing.
@@ -391,7 +391,7 @@ Existing applications do not need to change. SignalR mode is opt-in via command-
391391
## File Changes Summary
392392

393393
**New Files**:
394-
- `src/ElectronNET.AspNet/Bridge/SignalRFacade.cs` (225 lines)
394+
- `src/ElectronNET.AspNet/Bridge/SignalRConnection.cs` (225 lines)
395395
- `src/ElectronNET.AspNet/Hubs/ElectronHub.cs` (108 lines)
396396
- `src/ElectronNET.AspNet/Runtime/Controllers/RuntimeControllerAspNetDotnetFirstSignalR.cs` (163 lines)
397397
- `src/ElectronNET.AspNet/Services/IElectronAuthenticationService.cs` (20 lines)

docs/SignalR-Startup-Mode.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ The application will:
107107
### .NET Side
108108

109109
- **`ElectronHub`** - SignalR hub at `/electron-hub`
110-
- **`SignalRFacade`** - Mimics `SocketIoFacade` interface for compatibility
110+
- **`SignalRConnection`** - Mimics `SocketIOConnection` interface for compatibility
111111
- **`RuntimeControllerAspNetDotnetFirstSignalR`** - Lifecycle management
112112
- **`StartupMethod.PackagedDotnetFirstSignalR`** - For packaged apps
113113
- **`StartupMethod.UnpackedDotnetFirstSignalR`** - For debugging
@@ -128,7 +128,7 @@ The application will:
128128

129129
## Current Limitations (Phase 6 Work Needed)
130130

131-
⚠️ **Electron API Integration** - Existing Electron APIs (WindowManager, Dialog, etc.) still use SocketIoFacade. Full integration requires:
131+
⚠️ **Electron API Integration** - Existing Electron APIs (WindowManager, Dialog, etc.) still use SocketIOConnection. Full integration requires:
132132
- Refactoring APIs to work with both facades, or
133133
- Creating an adapter pattern
134134

@@ -158,7 +158,7 @@ The application will:
158158
- URL parameter handling
159159

160160
### Phase 4: API Bridge ✅ (Basic Structure)
161-
- `SignalRFacade` class
161+
- `SignalRConnection` class
162162
- Event handler system
163163
- Hub connection integration
164164

@@ -182,7 +182,7 @@ To fully utilize this feature, the following work is recommended:
182182
### .NET
183183
- `src/ElectronNET.API/Runtime/Data/StartupMethod.cs`
184184
- `src/ElectronNET.AspNet/Hubs/ElectronHub.cs`
185-
- `src/ElectronNET.AspNet/Bridge/SignalRFacade.cs`
185+
- `src/ElectronNET.AspNet/Bridge/SignalRConnection.cs`
186186
- `src/ElectronNET.AspNet/Runtime/Controllers/RuntimeControllerAspNetDotnetFirstSignalR.cs`
187187
- `src/ElectronNET.AspNet/API/ElectronEndpointRouteBuilderExtensions.cs`
188188
- `src/ElectronNET.AspNet/API/WebHostBuilderExtensions.cs`
@@ -200,8 +200,8 @@ To fully utilize this feature, the following work is recommended:
200200
8ee81f6 - Add ElectronHub and SignalR infrastructure for new startup modes
201201
40aed60 - Add RuntimeControllerAspNetDotnetFirstSignalR for SignalR-based startup
202202
c1740b5 - Add SignalR client support to Electron Host for new startup modes
203-
cb7d721 - Add SignalRFacade for SignalR-based API communication
204-
268b9c9 - Update RuntimeControllerAspNetDotnetFirstSignalR to use SignalRFacade
203+
cb7d721 - Add SignalRConnection for SignalR-based API communication
204+
268b9c9 - Update RuntimeControllerAspNetDotnetFirstSignalR to use SignalRConnection
205205
04ec522 - Fix compilation errors - Phase 4 complete (basic structure)
206206
054f5b1 - Complete Phase 5: Add SignalR startup detection and port 0 configuration
207207
```
@@ -219,7 +219,7 @@ cb7d721 - Add SignalRFacade for SignalR-based API communication
219219

220220
To contribute to Phase 6 (full API integration):
221221

222-
1. Focus on adapting existing Electron API classes to work with SignalRFacade
222+
1. Focus on adapting existing Electron API classes to work with SignalRConnection
223223
2. Implement request-response pattern in ElectronHub
224224
3. Add integration tests
225225
4. Create sample applications

src/ElectronNET.API/Bridge/BridgeConnector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace ElectronNET.API
66

77
internal static class BridgeConnector
88
{
9-
public static IFacade Socket
9+
public static ISocketConnection Socket
1010
{
1111
get
1212
{

src/ElectronNET.API/Bridge/IFacade.cs renamed to src/ElectronNET.API/Bridge/ISocketConnection.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace ElectronNET.API.Bridge
77
/// Common interface for communication facades (SocketIO and SignalR).
88
/// Provides methods for bidirectional communication between .NET and Electron.
99
/// </summary>
10-
internal interface IFacade
10+
internal interface ISocketConnection : IDisposable
1111
{
1212
/// <summary>
1313
/// Raised when the bridge connection is established.
@@ -53,10 +53,5 @@ internal interface IFacade
5353
/// Sends a message to Electron.
5454
/// </summary>
5555
Task Emit(string eventName, params object[] args);
56-
57-
/// <summary>
58-
/// Disposes the connection.
59-
/// </summary>
60-
void DisposeSocket();
6156
}
6257
}

src/ElectronNET.API/Bridge/SocketIOFacade.cs renamed to src/ElectronNET.API/Bridge/SocketIOConnection.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ namespace ElectronNET.API;
99
using SocketIO.Serializer.SystemTextJson;
1010
using SocketIO = SocketIOClient.SocketIO;
1111

12-
internal class SocketIoFacade : IFacade, IDisposable
12+
internal class SocketIOConnection : ISocketConnection
1313
{
1414
private readonly SocketIO _socket;
1515
private readonly object _lockObj = new object();
1616
private bool _isDisposed;
1717

18-
public SocketIoFacade(string uri)
18+
public SocketIOConnection(string uri)
1919
{
2020
_socket = new SocketIO(uri);
2121
_socket.Serializer = new SystemTextJsonSerializer(ElectronJson.Options);
@@ -141,7 +141,7 @@ private void CheckDisposed()
141141
{
142142
if (this._isDisposed)
143143
{
144-
throw new ObjectDisposedException(nameof(SocketIoFacade));
144+
throw new ObjectDisposedException(nameof(SocketIOConnection));
145145
}
146146
}
147147
}

src/ElectronNET.API/ElectronNetRuntime.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static ElectronNetRuntime()
5050

5151
internal static Func<Task> OnAppReadyCallback { get; set; }
5252

53-
internal static IFacade GetSocket()
53+
internal static ISocketConnection GetSocket()
5454
{
5555
return RuntimeControllerCore?.Socket;
5656
}

src/ElectronNET.API/Runtime/Controllers/RuntimeControllerBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ protected RuntimeControllerBase()
1313
{
1414
}
1515

16-
internal abstract IFacade Socket { get; }
16+
internal abstract ISocketConnection Socket { get; }
1717

1818
internal abstract ElectronProcessBase ElectronProcess { get; }
1919

src/ElectronNET.API/Runtime/Controllers/RuntimeControllerDotNetFirst.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public RuntimeControllerDotNetFirst()
2020
{
2121
}
2222

23-
internal override IFacade Socket
23+
internal override ISocketConnection Socket
2424
{
2525
get
2626
{

src/ElectronNET.API/Runtime/Controllers/RuntimeControllerElectronFirst.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public RuntimeControllerElectronFirst()
1717
{
1818
}
1919

20-
internal override SocketIoFacade Socket
20+
internal override SocketIOConnection Socket
2121
{
2222
get
2323
{

src/ElectronNET.API/Runtime/Services/SocketBridge/SocketBridgeService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ internal class SocketBridgeService : LifetimeServiceBase
99
{
1010
private readonly int socketPort;
1111
private readonly string socketUrl;
12-
private SocketIoFacade socket;
12+
private SocketIOConnection socket;
1313

1414
public SocketBridgeService(int socketPort)
1515
{
@@ -19,11 +19,11 @@ public SocketBridgeService(int socketPort)
1919

2020
public int SocketPort => this.socketPort;
2121

22-
internal SocketIoFacade Socket => this.socket;
22+
internal SocketIOConnection Socket => this.socket;
2323

2424
protected override Task StartCore()
2525
{
26-
this.socket = new SocketIoFacade(this.socketUrl);
26+
this.socket = new SocketIOConnection(this.socketUrl);
2727
this.socket.BridgeConnected += this.Socket_BridgeConnected;
2828
this.socket.BridgeDisconnected += this.Socket_BridgeDisconnected;
2929
Task.Run(this.Connect);

0 commit comments

Comments
 (0)