Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite to signalr #670

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
937 changes: 369 additions & 568 deletions ElectronNET.API/App.cs

Large diffs are not rendered by default.

426 changes: 132 additions & 294 deletions ElectronNET.API/AutoUpdater.cs

Large diffs are not rendered by default.

44 changes: 0 additions & 44 deletions ElectronNET.API/BridgeConnector.cs

This file was deleted.

15 changes: 13 additions & 2 deletions ElectronNET.API/BridgeSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,25 @@ public static class BridgeSettings
/// <value>
/// The socket port.
/// </value>
public static string SocketPort { get; internal set; }
public static string SocketPort { get; set; }

/// <summary>
/// Gets the web port.
/// </summary>
/// <value>
/// The web port.
/// </value>
public static string WebPort { get; internal set; }
public static string WebPort { get; set; }

/// <summary>
/// Manually set the port values instead of using the UseElectron extension method
/// </summary>
/// <param name="socketPort"></param>
/// <param name="webPort"></param>
public static void InitializePorts(int socketPort, int webPort)
{
SocketPort = socketPort.ToString();
WebPort = webPort.ToString();
}
}
}
41 changes: 16 additions & 25 deletions ElectronNET.API/BrowserView.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ElectronNET.API.Entities;
using Microsoft.AspNetCore.SignalR;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
Expand Down Expand Up @@ -31,29 +32,19 @@ public class BrowserView
///
/// (experimental)
/// </summary>
public Rectangle Bounds
public async Task<Rectangle> GetBoundsAsync()
{
get
{
return Task.Run<Rectangle>(() =>
{
var taskCompletionSource = new TaskCompletionSource<Rectangle>();

BridgeConnector.Socket.On("browserView-getBounds-reply", (result) =>
{
BridgeConnector.Socket.Off("browserView-getBounds-reply");
taskCompletionSource.SetResult((Rectangle)result);
});

BridgeConnector.Socket.Emit("browserView-getBounds", Id);
var signalrResult = await SignalrSerializeHelper.GetSignalrResultJObject("browserView-getBounds", Id);
return ((JObject)signalrResult).ToObject<Rectangle>();
}

return taskCompletionSource.Task;
}).Result;
}
set
{
BridgeConnector.Socket.Emit("browserView-setBounds", Id, JObject.FromObject(value, _jsonSerializer));
}
/// <summary>
/// Set the bounds of the current view inside the window
/// </summary>
/// <param name="value"></param>
public async void SetBounds(Rectangle value)
{
await Electron.SignalrElectron.Clients.All.SendAsync("browserView-setBounds", Id, JObject.FromObject(value, _jsonSerializer));
}

/// <summary>
Expand All @@ -72,9 +63,9 @@ internal BrowserView(int id)
/// (experimental)
/// </summary>
/// <param name="options"></param>
public void SetAutoResize(AutoResizeOptions options)
public async void SetAutoResize(AutoResizeOptions options)
{
BridgeConnector.Socket.Emit("browserView-setAutoResize", Id, JObject.FromObject(options, _jsonSerializer));
await Electron.SignalrElectron.Clients.All.SendAsync("browserView-setAutoResize", Id, JObject.FromObject(options, _jsonSerializer));
}

/// <summary>
Expand All @@ -83,9 +74,9 @@ public void SetAutoResize(AutoResizeOptions options)
/// (experimental)
/// </summary>
/// <param name="color">Color in #aarrggbb or #argb form. The alpha channel is optional.</param>
public void SetBackgroundColor(string color)
public async void SetBackgroundColor(string color)
{
BridgeConnector.Socket.Emit("browserView-setBackgroundColor", Id, color);
await Electron.SignalrElectron.Clients.All.SendAsync("browserView-setBackgroundColor", Id, color);
}

private JsonSerializer _jsonSerializer = new JsonSerializer()
Expand Down