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 7 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
782 changes: 224 additions & 558 deletions ElectronNET.API/App.cs

Large diffs are not rendered by default.

299 changes: 95 additions & 204 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.

4 changes: 2 additions & 2 deletions ElectronNET.API/BridgeSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ 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; }
}
}
22 changes: 8 additions & 14 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 @@ -38,21 +39,14 @@ public Rectangle Bounds
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 = SignalrSerializeHelper.GetSignalrResultJObject("browserView-getBounds", Id).Result;
taskCompletionSource.SetResult(((JObject)signalrResult).ToObject<Rectangle>());
return taskCompletionSource.Task;
}).Result;
}
set
{
BridgeConnector.Socket.Emit("browserView-setBounds", Id, JObject.FromObject(value, _jsonSerializer));
Electron.SignalrElectron.Clients.All.SendAsync("browserView-setBounds", Id, JObject.FromObject(value, _jsonSerializer));
}
}

Expand All @@ -72,9 +66,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 +77,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