mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2026-06-13 14:38:43 +00:00
a
This commit is contained in:
@@ -532,8 +532,8 @@ public partial class EpConnection : NetworkConnection, IStore
|
||||
EpRequestUnsubscribe(_packet.CallbackId, dt);
|
||||
break;
|
||||
// Inquire
|
||||
case EpPacketRequest.TypeDefByName:
|
||||
EpRequestTypeDefByName(_packet.CallbackId, dt);
|
||||
case EpPacketRequest.TypeDefIdsByNames:
|
||||
EpRequestTypeDefIdsByNames(_packet.CallbackId, dt);
|
||||
break;
|
||||
case EpPacketRequest.TypeDefById:
|
||||
EpRequestTypeDefById(_packet.CallbackId, dt);
|
||||
@@ -736,7 +736,7 @@ public partial class EpConnection : NetworkConnection, IStore
|
||||
}
|
||||
|
||||
SendAuthHeaders(EpAuthPacketMethod.SessionEstablished, localHeaders);
|
||||
|
||||
|
||||
_session.Authenticated = true;
|
||||
_session.LocalIdentity = null;
|
||||
_session.RemoteIdentity = null;
|
||||
@@ -1031,7 +1031,7 @@ public partial class EpConnection : NetworkConnection, IStore
|
||||
|
||||
|
||||
|
||||
void AuthenticatonCompleted()
|
||||
async Task AuthenticatonCompleted()
|
||||
{
|
||||
|
||||
if (this.Instance == null)
|
||||
@@ -1062,12 +1062,50 @@ public partial class EpConnection : NetworkConnection, IStore
|
||||
{
|
||||
_authenticated = true;
|
||||
Status = EpConnectionStatus.Connected;
|
||||
_openReply?.Trigger(true);
|
||||
_openReply = null;
|
||||
OnReady?.Invoke(this);
|
||||
|
||||
_session.AuthenticationHandler?.Provider?.Login(_session);
|
||||
//Server?.Membership?.Login(_session);
|
||||
|
||||
|
||||
OnReady?.Invoke(this);
|
||||
|
||||
var proxyTypes = Instance.Warehouse.GetProxyTypesByDomain(_remoteDomain);
|
||||
|
||||
var typeDefNames = new List<string>();
|
||||
|
||||
foreach (var kk in proxyTypes)
|
||||
{
|
||||
foreach (var kv in kk.Value)
|
||||
{
|
||||
typeDefNames.Add(kv.Key);
|
||||
}
|
||||
}
|
||||
if (typeDefNames.Count > 0)
|
||||
{
|
||||
GetTypeDefIds(typeDefNames.ToArray()).Then(ids =>
|
||||
{
|
||||
var bag = new AsyncBag<object>();
|
||||
foreach (var id in ids)
|
||||
bag.Add(FetchTypeDef(id, null));
|
||||
|
||||
bag.Seal();
|
||||
|
||||
bag.Then((o) =>
|
||||
{
|
||||
_openReply?.Trigger(true);
|
||||
_openReply = null;
|
||||
});
|
||||
}).Error(ex =>
|
||||
{
|
||||
_openReply.TriggerError(ex);
|
||||
// do nothing, proxies won't work but connection is established
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
_openReply?.Trigger(true);
|
||||
_openReply = null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//private void ProcessClientAuth(byte[] data)
|
||||
|
||||
@@ -1011,17 +1011,25 @@ partial class EpConnection
|
||||
Instance.Warehouse.Query(resourceLink).Then(queryCallback);
|
||||
}
|
||||
|
||||
void EpRequestTypeDefByName(uint callback, PlainTdu tdu)
|
||||
void EpRequestTypeDefIdsByNames(uint callback, PlainTdu tdu)
|
||||
{
|
||||
var value = Codec.ParseSync(tdu, Instance.Warehouse);
|
||||
|
||||
var className = (string)value;
|
||||
var classNames = (string[])value;
|
||||
|
||||
var typeDef = Instance.Warehouse.GetRemoteTypeDefByName(_remoteDomain, className);
|
||||
var typeDefs = new List<ulong>();
|
||||
|
||||
if (typeDef != null)
|
||||
foreach (var className in classNames)
|
||||
{
|
||||
SendReply(EpPacketReply.Completed, callback, typeDef.Compose(this));
|
||||
//@TODO: need to search in remoteTypeDefs as well
|
||||
var typeDef = Instance.Warehouse.GetLocalTypeDefByName(className);
|
||||
if (typeDef != null)
|
||||
typeDefs.Add(typeDef.Id);
|
||||
}
|
||||
|
||||
if (typeDefs.Count > 0)
|
||||
{
|
||||
SendReply(EpPacketReply.Completed, callback, typeDefs.ToArray());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2567,6 +2575,18 @@ partial class EpConnection
|
||||
return reply;
|
||||
}
|
||||
|
||||
public AsyncReply<ulong[]> GetTypeDefIds(string[] fullNames)
|
||||
{
|
||||
var reply = new AsyncReply<ulong[]>();
|
||||
|
||||
SendRequest(EpPacketRequest.TypeDefIdsByNames, fullNames)
|
||||
.Then(result =>
|
||||
{
|
||||
reply.Trigger((ulong[])result);
|
||||
}).Error(ex => reply.TriggerError(ex));
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new resource.
|
||||
|
||||
Reference in New Issue
Block a user