|
|
@ -8,16 +8,6 @@ namespace ZeroLevel.Network
|
|
|
|
internal sealed class ExClientServerCachee
|
|
|
|
internal sealed class ExClientServerCachee
|
|
|
|
: IDisposable
|
|
|
|
: IDisposable
|
|
|
|
{
|
|
|
|
{
|
|
|
|
internal event Action<IPEndPoint> OnBrokenConnection;
|
|
|
|
|
|
|
|
private void RiseBrokenConnectionEvent(IPEndPoint endpoint)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var e = OnBrokenConnection;
|
|
|
|
|
|
|
|
if (e != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
e.Invoke(endpoint);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static readonly ConcurrentDictionary<string, ExClient> _clientInstances = new ConcurrentDictionary<string, ExClient>();
|
|
|
|
private static readonly ConcurrentDictionary<string, ExClient> _clientInstances = new ConcurrentDictionary<string, ExClient>();
|
|
|
|
|
|
|
|
|
|
|
|
private readonly ConcurrentDictionary<string, SocketServer> _serverInstances = new ConcurrentDictionary<string, SocketServer>();
|
|
|
|
private readonly ConcurrentDictionary<string, SocketServer> _serverInstances = new ConcurrentDictionary<string, SocketServer>();
|
|
|
@ -44,12 +34,8 @@ namespace ZeroLevel.Network
|
|
|
|
}
|
|
|
|
}
|
|
|
|
instance = new ExClient(new SocketClient(endpoint, router ?? new Router()));
|
|
|
|
instance = new ExClient(new SocketClient(endpoint, router ?? new Router()));
|
|
|
|
instance.ForceConnect();
|
|
|
|
instance.ForceConnect();
|
|
|
|
if (instance.Status != SocketClientStatus.Initialized &&
|
|
|
|
if (instance.Status == SocketClientStatus.Initialized
|
|
|
|
instance.Status != SocketClientStatus.Working)
|
|
|
|
||instance.Status == SocketClientStatus.Working)
|
|
|
|
{
|
|
|
|
|
|
|
|
OnBrokenConnection(endpoint);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_clientInstances[key] = instance;
|
|
|
|
_clientInstances[key] = instance;
|
|
|
|
return instance;
|
|
|
|
return instance;
|
|
|
@ -58,12 +44,8 @@ namespace ZeroLevel.Network
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var instance = new ExClient(new SocketClient(endpoint, router ?? new Router()));
|
|
|
|
var instance = new ExClient(new SocketClient(endpoint, router ?? new Router()));
|
|
|
|
if (instance.Status != SocketClientStatus.Initialized &&
|
|
|
|
if (instance.Status == SocketClientStatus.Initialized
|
|
|
|
instance.Status != SocketClientStatus.Working)
|
|
|
|
|| instance.Status == SocketClientStatus.Working)
|
|
|
|
{
|
|
|
|
|
|
|
|
OnBrokenConnection(endpoint);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return instance;
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
}
|
|
|
|