mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2026-06-13 14:38:43 +00:00
Ver 3
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,35 +0,0 @@
|
||||
using Esiur.Core;
|
||||
using Esiur.Data;
|
||||
using Esiur.Net.Packets;
|
||||
using Esiur.Security.Membership;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Esiur.Protocol;
|
||||
|
||||
public class EpConnectionConfig
|
||||
{
|
||||
public ExceptionLevel ExceptionLevel { get; set; }
|
||||
= ExceptionLevel.Code | ExceptionLevel.Message | ExceptionLevel.Source | ExceptionLevel.Trace;
|
||||
|
||||
public Func<AuthorizationRequest, AsyncReply<object>> Authenticator { get; set; }
|
||||
|
||||
public bool AutoReconnect { get; set; } = false;
|
||||
|
||||
public uint ReconnectInterval { get; set; } = 5;
|
||||
|
||||
public string Username { get; set; }
|
||||
|
||||
public bool UseWebSocket { get; set; }
|
||||
|
||||
public bool SecureWebSocket { get; set; }
|
||||
|
||||
public string Password { get; set; }
|
||||
|
||||
public string Token { get; set; }
|
||||
|
||||
public ulong TokenIndex { get; set; }
|
||||
|
||||
public string Domain { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using Esiur.Core;
|
||||
using Esiur.Data;
|
||||
using Esiur.Net.Packets;
|
||||
using Esiur.Resource;
|
||||
using Esiur.Security.Membership;
|
||||
using Esiur.Security.Permissions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Esiur.Protocol;
|
||||
|
||||
public class EpConnectionContext : ResourceContext
|
||||
{
|
||||
public EpConnectionContext()
|
||||
: base(0, new Map<string, object>(), null, null)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Build()
|
||||
{
|
||||
Attributes["AutoConnect"] = AutoReconnect;
|
||||
Attributes["ReconnectInterval"] = ReconnectInterval;
|
||||
Attributes["UseWebSocket"] = UseWebSocket;
|
||||
Attributes["SecureWebSocket"] = SecureWebSocket;
|
||||
Attributes["Domain"] = SecureWebSocket;
|
||||
Attributes["AuthenticationProtocol"] = SecureWebSocket;
|
||||
Attributes["Identity"] = SecureWebSocket;
|
||||
}
|
||||
|
||||
public ExceptionLevel ExceptionLevel { get; set; }
|
||||
= ExceptionLevel.Code | ExceptionLevel.Message | ExceptionLevel.Source | ExceptionLevel.Trace;
|
||||
|
||||
//public Func<AuthorizationRequest, AsyncReply<object>> Authenticator { get; set; }
|
||||
//public Func<AuthorizationRequest, AsyncReply<object>> Authenticator { get; set; }
|
||||
|
||||
public string Identity { get; set; }
|
||||
public string AuthenticationProtocol { get; set; }
|
||||
|
||||
public bool AutoReconnect { get; set; } = false;
|
||||
|
||||
public uint ReconnectInterval { get; set; } = 5;
|
||||
|
||||
//public string Username { get; set; }
|
||||
|
||||
public bool UseWebSocket { get; set; }
|
||||
|
||||
public bool SecureWebSocket { get; set; }
|
||||
|
||||
// public string Password { get; set; }
|
||||
|
||||
//public string Token { get; set; }
|
||||
|
||||
//public ulong TokenIndex { get; set; }
|
||||
|
||||
public string Domain { get; set; }
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -81,7 +81,7 @@ public class EpResource : DynamicObject, IResource, INotifyPropertyChanged, IDyn
|
||||
/// <summary>
|
||||
/// Connection responsible for the distributed resource.
|
||||
/// </summary>
|
||||
public EpConnection DistributedResourceConnection
|
||||
public EpConnection ResourceConnection
|
||||
{
|
||||
get { return connection; }
|
||||
}
|
||||
@@ -89,7 +89,7 @@ public class EpResource : DynamicObject, IResource, INotifyPropertyChanged, IDyn
|
||||
/// <summary>
|
||||
/// Resource link
|
||||
/// </summary>
|
||||
public string DistributedResourceLink
|
||||
public string ResourceLink
|
||||
{
|
||||
get { return link; }
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public class EpResource : DynamicObject, IResource, INotifyPropertyChanged, IDyn
|
||||
/// <summary>
|
||||
/// Instance Id given by the other end.
|
||||
/// </summary>
|
||||
public uint DistributedResourceInstanceId
|
||||
public uint ResourceInstanceId
|
||||
{
|
||||
get { return instanceId; }
|
||||
internal set { instanceId = value; }
|
||||
@@ -128,9 +128,9 @@ public class EpResource : DynamicObject, IResource, INotifyPropertyChanged, IDyn
|
||||
/// <summary>
|
||||
/// Resource is attached when all its properties are received.
|
||||
/// </summary>
|
||||
public bool DistributedResourceAttached => attached;
|
||||
public bool ResourceAttached => attached;
|
||||
|
||||
public bool DistributedResourceSuspended => suspended;
|
||||
public bool ResourceSuspended => suspended;
|
||||
|
||||
|
||||
// public DistributedResourceStack Stack
|
||||
@@ -216,10 +216,18 @@ public class EpResource : DynamicObject, IResource, INotifyPropertyChanged, IDyn
|
||||
public AsyncReply Subscribe(EventDef et)
|
||||
{
|
||||
if (et == null)
|
||||
return new AsyncReply().TriggerError(new AsyncException(ErrorType.Management, (ushort)ExceptionCode.MethodNotFound, ""));
|
||||
{
|
||||
var rt = new AsyncReply();
|
||||
rt.TriggerError(new AsyncException(ErrorType.Management, (ushort)ExceptionCode.MethodNotFound, ""));
|
||||
return rt;
|
||||
}
|
||||
|
||||
if (!et.Subscribable)
|
||||
return new AsyncReply().TriggerError(new AsyncException(ErrorType.Management, (ushort)ExceptionCode.NotSubscribable, ""));
|
||||
{
|
||||
var rt = new AsyncReply();
|
||||
rt.TriggerError(new AsyncException(ErrorType.Management, (ushort)ExceptionCode.NotSubscribable, ""));
|
||||
return rt;
|
||||
}
|
||||
|
||||
return connection.SendSubscribeRequest(instanceId, et.Index);
|
||||
}
|
||||
@@ -235,10 +243,18 @@ public class EpResource : DynamicObject, IResource, INotifyPropertyChanged, IDyn
|
||||
public AsyncReply Unsubscribe(EventDef et)
|
||||
{
|
||||
if (et == null)
|
||||
return new AsyncReply().TriggerError(new AsyncException(ErrorType.Management, (ushort)ExceptionCode.MethodNotFound, ""));
|
||||
{
|
||||
var rt = new AsyncReply();
|
||||
rt.TriggerError(new AsyncException(ErrorType.Management, (ushort)ExceptionCode.MethodNotFound, ""));
|
||||
return rt;
|
||||
}
|
||||
|
||||
if (!et.Subscribable)
|
||||
return new AsyncReply().TriggerError(new AsyncException(ErrorType.Management, (ushort)ExceptionCode.NotSubscribable, ""));
|
||||
{
|
||||
var rt = new AsyncReply();
|
||||
rt.TriggerError(new AsyncException(ErrorType.Management, (ushort)ExceptionCode.NotSubscribable, ""));
|
||||
return rt;
|
||||
}
|
||||
|
||||
return connection.SendUnsubscribeRequest(instanceId, et.Index);
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@ using System.Text;
|
||||
|
||||
namespace Esiur.Protocol;
|
||||
|
||||
internal class EpResourceAttachRequestInfo
|
||||
internal class FetchRequestInfo<TValue, TId>
|
||||
{
|
||||
public AsyncReply<EpResource> Reply { get; set; }
|
||||
public uint[] RequestSequence { get; set; }
|
||||
public AsyncReply<TValue> Reply { get; set; }
|
||||
public TId[] RequestSequence { get; set; }
|
||||
|
||||
public EpResourceAttachRequestInfo(AsyncReply<EpResource> reply, uint[] requestSequence)
|
||||
public FetchRequestInfo(AsyncReply<TValue> reply, TId[] requestSequence)
|
||||
{
|
||||
Reply = reply;
|
||||
RequestSequence = requestSequence;
|
||||
|
||||
@@ -184,7 +184,7 @@ public class EpServer : NetworkServer<EpConnection>, IResource
|
||||
|
||||
public EpServer MapCall(string call, Delegate handler)
|
||||
{
|
||||
var fd = FunctionDef.MakeFunctionDef(null, handler.Method, 0, call, null);
|
||||
var fd = FunctionDef.MakeFunctionDef(Instance.Warehouse, null, handler.Method, 0, call, null);
|
||||
Calls.Add(call, new CallInfo() { Delegate = handler, Definition = fd });
|
||||
return this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user