2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-05-06 19:42:58 +00:00
This commit is contained in:
Ahmed Zamil 2021-05-26 08:55:42 +03:00
parent 82cbe3b01c
commit ece7c7d08f
10 changed files with 36 additions and 26 deletions

View File

@ -207,7 +207,7 @@ namespace Esiur.Stores.EntityCore
return new AsyncReply<bool>(true); return new AsyncReply<bool>(true);
} }
void ReloadModel() public void ReloadModel()
{ {
TypesByName.Clear(); TypesByName.Clear();

View File

@ -123,7 +123,7 @@ namespace Esiur.Stores.EntityCore
await Warehouse.Put(id.ToString(), res, store, null, null, 0, manager); await Warehouse.Put(id.ToString(), res, store, null, null, 0, manager);
return resource; return (T)res;
} }
//public static async AsyncReply<T> CreateResourceAsync<T>(this IServiceProvider serviceProvider, T properties = null) where T : class, IResource //public static async AsyncReply<T> CreateResourceAsync<T>(this IServiceProvider serviceProvider, T properties = null) where T : class, IResource

View File

@ -923,7 +923,7 @@ namespace Esiur.Data
var index = data[offset++]; var index = data[offset++];
var pt = resource.Instance.Template.GetPropertyTemplateByIndex(index); var pt = resource.Instance.Template.GetPropertyTemplateByIndex(index);
list.Add(pt, null); list.Add(pt, null);
var cs = DC.GetUInt32(data, offset); var cs = data.GetUInt32(offset);
offset += 4; offset += 4;
bagOfBags.Add(ParsePropertyValueArray(data, offset, cs, connection)); bagOfBags.Add(ParsePropertyValueArray(data, offset, cs, connection));
offset += cs; offset += cs;

View File

@ -869,6 +869,15 @@ namespace Esiur.Net.IIP
//Global.Log("auth", LogType.Warning, "U:" + RemoteUsername + " IP:" + Socket.RemoteEndPoint.Address.ToString() + " S:AUTH"); //Global.Log("auth", LogType.Warning, "U:" + RemoteUsername + " IP:" + Socket.RemoteEndPoint.Address.ToString() + " S:AUTH");
} }
else
{
SendParams()
.AddUInt8(0xc0)
.AddUInt8((byte)ExceptionCode.GeneralFailure)
.AddUInt16(9)
.AddString("Not ready")
.Done();
}
} }
} }
} }
@ -876,15 +885,16 @@ namespace Esiur.Net.IIP
{ {
if (authPacket.Command == IIPAuthPacket.IIPAuthPacketCommand.Acknowledge) if (authPacket.Command == IIPAuthPacket.IIPAuthPacketCommand.Acknowledge)
{ {
if (authPacket.LocalMethod == AuthenticationMethod.None) if (authPacket.RemoteMethod == AuthenticationMethod.None)
{ {
// send establish
SendParams() SendParams()
.AddUInt8(0x20) .AddUInt8(0x20)
.AddUInt16(0) .AddUInt16(0)
.Done(); .Done();
} }
else if (authPacket.LocalMethod == AuthenticationMethod.Credentials else if (authPacket.RemoteMethod == AuthenticationMethod.Credentials
|| authPacket.LocalMethod == AuthenticationMethod.Token) || authPacket.RemoteMethod == AuthenticationMethod.Token)
{ {
remoteNonce = authPacket.RemoteNonce; remoteNonce = authPacket.RemoteNonce;

View File

@ -1098,7 +1098,7 @@ namespace Esiur.Net.IIP
var templates = new List<ResourceTemplate>(); var templates = new List<ResourceTemplate>();
foreach (var resource in list) foreach (var resource in list)
templates.AddRange(ResourceTemplate.GetRuntimeTypes(resource.Instance.Template).Where(x => !templates.Contains(x))); templates.AddRange(ResourceTemplate.GetDependencies(resource.Instance.Template).Where(x => !templates.Contains(x)));
foreach(var t in templates) foreach(var t in templates)
{ {
@ -2210,8 +2210,8 @@ namespace Esiur.Net.IIP
if (resource == null) if (resource == null)
{ {
var template = Warehouse.GetTemplate((Guid)rt[0]); var template = Warehouse.GetTemplate((Guid)rt[0]);
if (template?.RuntimeType != null) if (template?.ResourceType != null)
dr = Activator.CreateInstance(template.RuntimeType, this, id, (ulong)rt[1], (string)rt[2]) as DistributedResource; dr = Activator.CreateInstance(template.ResourceType, this, id, (ulong)rt[1], (string)rt[2]) as DistributedResource;
else else
dr = new DistributedResource(this, id, (ulong)rt[1], (string)rt[2]); dr = new DistributedResource(this, id, (ulong)rt[1], (string)rt[2]);
} }

View File

@ -146,7 +146,7 @@ namespace Esiur.Net.Packets
//Console.WriteLine("stage 2 " + needed); //Console.WriteLine("stage 2 " + needed);
return length - needed; return length - needed;
} }
PayloadLength = DC.GetUInt16(data, offset); PayloadLength = data.GetUInt16( offset);
offset += 2; offset += 2;
} }
else if (PayloadLength == 127) else if (PayloadLength == 127)
@ -158,7 +158,7 @@ namespace Esiur.Net.Packets
return length - needed; return length - needed;
} }
PayloadLength = DC.GetInt64(data, offset); PayloadLength = data.GetInt64(offset);
offset += 8; offset += 8;
} }

View File

@ -40,7 +40,7 @@ namespace Esiur.Resource
//public delegate void CustomReceiversEventHanlder(DistributedConnection[] connections, params object[] args); //public delegate void CustomReceiversEventHanlder(DistributedConnection[] connections, params object[] args);
//public delegate void CustomInquirerEventHanlder(object inquirer, params object[] args); //public delegate void CustomInquirerEventHanlder(object inquirer, params object[] args);
public delegate void CustomResourceEventHanlder<T>(object issuer, Func<Session, bool> receivers, T argument);// object issuer, Session[] receivers, params object[] args); public delegate void CustomResourceEventHanlder<in T>(object issuer, Func<Session, bool> receivers, T argument);// object issuer, Session[] receivers, params object[] args);
// public delegate void CustomReceiversEventHanlder(string[] usernames, DistributedConnection[] connections, params object[] args); // public delegate void CustomReceiversEventHanlder(string[] usernames, DistributedConnection[] connections, params object[] args);

View File

@ -17,7 +17,7 @@ namespace Esiur.Resource.Template
public static (uint, ArgumentTemplate) Parse(byte[] data, uint offset) public static (uint, ArgumentTemplate) Parse(byte[] data, uint offset)
{ {
var cs = (uint)data[offset++]; var cs = (uint)data[offset++];
var name = DC.GetString(data, offset, cs); var name = data.GetString(offset, cs);
offset += cs; offset += cs;
var (size, type) = TemplateDataType.Parse(data, offset); var (size, type) = TemplateDataType.Parse(data, offset);

View File

@ -32,7 +32,7 @@ namespace Esiur.Resource.Template
get { return content; } get { return content; }
} }
public Type RuntimeType { get; set; } public Type ResourceType { get; set; }
public MemberTemplate GetMemberTemplate(MemberInfo member) public MemberTemplate GetMemberTemplate(MemberInfo member)
{ {
@ -157,18 +157,18 @@ namespace Esiur.Resource.Template
public static ResourceTemplate[] GetRuntimeTypes(ResourceTemplate template) public static ResourceTemplate[] GetDependencies(ResourceTemplate template)
{ {
var list = new List<ResourceTemplate>(); var list = new List<ResourceTemplate>();
list.Add(template); list.Add(template);
Action<ResourceTemplate, List<ResourceTemplate>> getRuntimeTypes = null; Action<ResourceTemplate, List<ResourceTemplate>> getDependenciesFunc = null;
getRuntimeTypes = (ResourceTemplate tmp, List<ResourceTemplate> bag) => getDependenciesFunc = (ResourceTemplate tmp, List<ResourceTemplate> bag) =>
{ {
if (template.RuntimeType == null) if (template.ResourceType == null)
return; return;
// functions // functions
@ -180,7 +180,7 @@ namespace Esiur.Resource.Template
if (!bag.Contains(frtt)) if (!bag.Contains(frtt))
{ {
list.Add(frtt); list.Add(frtt);
getRuntimeTypes(frtt, bag); getDependenciesFunc(frtt, bag);
} }
} }
@ -194,7 +194,7 @@ namespace Esiur.Resource.Template
if (!bag.Contains(fpt)) if (!bag.Contains(fpt))
{ {
bag.Add(fpt); bag.Add(fpt);
getRuntimeTypes(fpt, bag); getDependenciesFunc(fpt, bag);
} }
} }
} }
@ -211,7 +211,7 @@ namespace Esiur.Resource.Template
if (!bag.Contains(fpt)) if (!bag.Contains(fpt))
{ {
bag.Add(fpt); bag.Add(fpt);
getRuntimeTypes(fpt, bag); getDependenciesFunc(fpt, bag);
} }
} }
} }
@ -228,7 +228,7 @@ namespace Esiur.Resource.Template
if (!bag.Contains(pt)) if (!bag.Contains(pt))
{ {
bag.Add(pt); bag.Add(pt);
getRuntimeTypes(pt, bag); getDependenciesFunc(pt, bag);
} }
} }
} }
@ -243,13 +243,13 @@ namespace Esiur.Resource.Template
if (!bag.Contains(et)) if (!bag.Contains(et))
{ {
bag.Add(et); bag.Add(et);
getRuntimeTypes(et, bag); getDependenciesFunc(et, bag);
} }
} }
} }
}; };
getRuntimeTypes(template, list); getDependenciesFunc(template, list);
return list.ToArray(); return list.ToArray();
} }
@ -260,7 +260,7 @@ namespace Esiur.Resource.Template
type = ResourceProxy.GetBaseType(type); type = ResourceProxy.GetBaseType(type);
RuntimeType = type; ResourceType = type;
className = type.FullName; className = type.FullName;

View File

@ -108,7 +108,7 @@ namespace Esiur.Resource.Template
// type == DataType.Structure || // type == DataType.Structure ||
// type == DataType.StructureArray) // type == DataType.StructureArray)
{ {
var guid = DC.GetGuid(data, offset); var guid = data.GetGuid(offset);
return (17, new TemplateDataType() { Type = type, TypeGuid = guid }); return (17, new TemplateDataType() { Type = type, TypeGuid = guid });
} }
else else