Files
Electron.NET/ElectronNET.API/BridgeConnector.cs

33 lines
914 B
C#
Raw Permalink Normal View History

2023-03-23 14:02:46 +01:00
namespace ElectronNET.API
2017-10-14 17:58:16 +02:00
{
internal static class BridgeConnector
{
2023-03-23 14:02:46 +01:00
private static SocketIoFacade _socket;
private static readonly object SyncRoot = new();
2017-10-14 17:58:16 +02:00
2023-03-23 14:02:46 +01:00
public static SocketIoFacade Socket
2017-10-14 17:58:16 +02:00
{
2017-10-23 21:24:05 +02:00
get
2017-10-14 17:58:16 +02:00
{
2023-03-23 14:02:46 +01:00
if (_socket == null)
2017-10-23 21:24:05 +02:00
{
2023-03-23 14:02:46 +01:00
lock (SyncRoot)
2017-10-23 21:24:05 +02:00
{
2023-03-23 14:02:46 +01:00
if (_socket == null)
2017-11-04 00:16:14 +01:00
{
2023-03-23 14:02:46 +01:00
string socketUrl = HybridSupport.IsElectronActive
? $"http://localhost:{BridgeSettings.SocketPort}"
: "http://localhost";
_socket = new SocketIoFacade(socketUrl);
_socket.Connect();
2017-11-04 00:16:14 +01:00
}
}
2017-10-23 21:24:05 +02:00
}
return _socket;
}
2017-10-14 17:58:16 +02:00
}
}
2023-03-23 14:02:46 +01:00
}