mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-10 21:23:53 +00:00
* Cleanup of unnecessary usings * Used language keywords instead of BCL types : Object --> object * Fixed some spelling issues
45 lines
1.4 KiB
C#
45 lines
1.4 KiB
C#
using Quobject.SocketIoClientDotNet.Client;
|
|
using System;
|
|
|
|
namespace ElectronNET.API
|
|
{
|
|
internal static class BridgeConnector
|
|
{
|
|
private static Socket _socket;
|
|
private static object _syncRoot = new object();
|
|
|
|
public static Socket Socket
|
|
{
|
|
get
|
|
{
|
|
if(_socket == null && HybridSupport.IsElectronActive)
|
|
{
|
|
lock (_syncRoot)
|
|
{
|
|
if (_socket == null && HybridSupport.IsElectronActive)
|
|
{
|
|
_socket = IO.Socket("http://localhost:" + BridgeSettings.SocketPort);
|
|
_socket.On(Socket.EVENT_CONNECT, () =>
|
|
{
|
|
Console.WriteLine("BridgeConnector connected!");
|
|
});
|
|
}
|
|
}
|
|
}
|
|
else if(_socket == null && !HybridSupport.IsElectronActive)
|
|
{
|
|
lock (_syncRoot)
|
|
{
|
|
if (_socket == null && !HybridSupport.IsElectronActive)
|
|
{
|
|
_socket = IO.Socket(new Uri("http://localhost"), new IO.Options { AutoConnect = false });
|
|
}
|
|
}
|
|
}
|
|
|
|
return _socket;
|
|
}
|
|
}
|
|
}
|
|
}
|