mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2026-06-13 14:38:43 +00:00
RPC Test
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Esiur.Data.Types;
|
||||
using Esiur.Protocol;
|
||||
using Esiur.Resource;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
@@ -28,9 +29,10 @@ namespace Esiur.Data
|
||||
TypeDef = typeDef;
|
||||
|
||||
if (typeDef is LocalTypeDef localTypeDef)
|
||||
RuntimeType = localTypeDef.DefinedType;
|
||||
RuntimeType = localTypeDef.DefinedType ?? typeof(EpResource);
|
||||
else if (typeDef is RemoteTypeDef remoteTypeDef)
|
||||
RuntimeType = remoteTypeDef.ProxyType;
|
||||
RuntimeType = remoteTypeDef.ProxyType ?? typeof(IResource);
|
||||
|
||||
}
|
||||
|
||||
public override void SetNull(byte flag)
|
||||
|
||||
@@ -1831,18 +1831,21 @@ public partial class EpConnection : NetworkConnection, IStore
|
||||
// assign domain from hostname if not provided
|
||||
if (context is EpConnectionContext epContext)
|
||||
{
|
||||
var provider = Instance.Warehouse.GetAuthenticationProvider(epContext.AuthenticationProtocol);
|
||||
var provider = Instance.Warehouse.TryGetAuthenticationProvider(epContext.AuthenticationProtocol);
|
||||
|
||||
_remoteDomain = epContext.Domain ?? address;
|
||||
|
||||
_session.AuthenticationHandler = provider.CreateAuthenticationHandler(new AuthenticationContext()
|
||||
if (provider != null)
|
||||
{
|
||||
Direction = AuthenticationDirection.Initiator,
|
||||
Domain = _remoteDomain,
|
||||
HostName = address,
|
||||
InitiatorIdentity = epContext.Identity,
|
||||
Mode = epContext.AuthenticationMode,
|
||||
});
|
||||
_session.AuthenticationHandler = provider.CreateAuthenticationHandler(new AuthenticationContext()
|
||||
{
|
||||
Direction = AuthenticationDirection.Initiator,
|
||||
Domain = _remoteDomain,
|
||||
HostName = address,
|
||||
InitiatorIdentity = epContext.Identity,
|
||||
Mode = epContext.AuthenticationMode,
|
||||
});
|
||||
}
|
||||
|
||||
_session.AuthenticationMode = epContext.AuthenticationMode;
|
||||
_session.LocalIdentity = epContext.Identity;
|
||||
|
||||
@@ -2035,30 +2035,32 @@ partial class EpConnection
|
||||
|
||||
public AsyncReply<RemoteTypeDef[]> GetLinkDefinitions(string link)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
//throw new NotImplementedException();
|
||||
|
||||
//var reply = new AsyncReply<RemoteTypeDef[]>();
|
||||
var reply = new AsyncReply<RemoteTypeDef[]>();
|
||||
|
||||
|
||||
//SendRequest(EpPacketRequest.LinkTypeDefs, link)
|
||||
//.Then((result) =>
|
||||
//{
|
||||
SendRequest(EpPacketRequest.LinkTypeDefs, link)
|
||||
.Then(async (result) =>
|
||||
{
|
||||
|
||||
// var defs = new List<RemoteTypeDef>();
|
||||
var defs = new List<RemoteTypeDef>();
|
||||
|
||||
// foreach (var def in (byte[][])result)
|
||||
// {
|
||||
// defs.Add(RemoteTypeDef.Parse(_remoteDomain, def));
|
||||
// }
|
||||
foreach (var def in (byte[][])result)
|
||||
{
|
||||
var od = new RemoteTypeDef();
|
||||
await RemoteTypeDef.Parse(od, _remoteDomain, def, this, null);
|
||||
defs.Add(od);
|
||||
}
|
||||
|
||||
// reply.Trigger(defs.ToArray());
|
||||
reply.Trigger(defs.ToArray());
|
||||
|
||||
//}).Error((ex) =>
|
||||
//{
|
||||
// reply.TriggerError(ex);
|
||||
//});
|
||||
}).Error((ex) =>
|
||||
{
|
||||
reply.TriggerError(ex);
|
||||
});
|
||||
|
||||
//return reply;
|
||||
return reply;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -220,6 +220,7 @@ public static class TypeDefGenerator
|
||||
var path = urlRegex.Split(url);
|
||||
var con = Warehouse.Default.Get<EpConnection>(path[1] + "://" + path[2], new EpConnectionContext()
|
||||
{
|
||||
AuthenticationMode = Security.Authority.AuthenticationMode.None,
|
||||
Identity = username
|
||||
}).Wait(10000);
|
||||
|
||||
|
||||
@@ -128,6 +128,15 @@ public class Warehouse
|
||||
throw new Exception("Authentication provider not found.");
|
||||
}
|
||||
|
||||
public IAuthenticationProvider? TryGetAuthenticationProvider(string name)
|
||||
{
|
||||
if (_authenticationProviders.ContainsKey(name))
|
||||
return _authenticationProviders[name];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public Warehouse()
|
||||
{
|
||||
Protocols.Add("EP",
|
||||
|
||||
Reference in New Issue
Block a user