2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-05-06 11:32:59 +00:00

Query Resource

This commit is contained in:
Ahmed Zamil 2019-12-07 06:01:23 +03:00
parent f66a809836
commit 128972bb74
5 changed files with 21 additions and 17 deletions

View File

@ -7,7 +7,7 @@
<PackageLicenseUrl>https://github.com/Esyur/Esyur-dotnet/blob/master/LICENSE</PackageLicenseUrl> <PackageLicenseUrl>https://github.com/Esyur/Esyur-dotnet/blob/master/LICENSE</PackageLicenseUrl>
<PackageProjectUrl>http://www.esyur.com</PackageProjectUrl> <PackageProjectUrl>http://www.esyur.com</PackageProjectUrl>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.4.2</Version> <Version>1.4.3</Version>
<RepositoryUrl>https://github.com/esyur/esyur-dotnet</RepositoryUrl> <RepositoryUrl>https://github.com/esyur/esyur-dotnet</RepositoryUrl>
<Authors>Ahmed Kh. Zamil</Authors> <Authors>Ahmed Kh. Zamil</Authors>
<AssemblyVersion>1.3.1.0</AssemblyVersion> <AssemblyVersion>1.3.1.0</AssemblyVersion>

View File

@ -798,13 +798,12 @@ namespace Esyur.Net.IIP
if (Instance.Attributes.ContainsKey("username") if (Instance.Attributes.ContainsKey("username")
&& Instance.Attributes.ContainsKey("password")) && Instance.Attributes.ContainsKey("password"))
{ {
//var hostname = String.Join("://", Instance.Name.Split(new string[] { "://" }, StringSplitOptions.None).Skip(1)).Split('/')[0];
// assign domain from hostname if not provided // assign domain from hostname if not provided
var host = Instance.Name.Split(':'); var host = Instance.Name.Split(':');
var address = host[0];// hostname.Split(':')[0]; var address = host[0];
var port = ushort.Parse(host[1]);// hostname.Split(':')[1]); var port = ushort.Parse(host[1]);
var username = Instance.Attributes["username"].ToString(); var username = Instance.Attributes["username"].ToString();
var domain = Instance.Attributes.ContainsKey("domain") ? Instance.Attributes["domain"].ToString() : address; var domain = Instance.Attributes.ContainsKey("domain") ? Instance.Attributes["domain"].ToString() : address;

View File

@ -1058,8 +1058,10 @@ namespace Esyur.Net.IIP
Action<IResource[]> queryCallback = (r) => Action<IResource[]> queryCallback = (r) =>
{ {
//if (r != null) if (r == null)
//{ SendError(ErrorType.Management, callback, (ushort)ExceptionCode.ResourceNotFound);
else
{
var list = r.Where(x => x.Instance.Applicable(session, ActionType.Attach, null) != Ruling.Denied).ToArray(); var list = r.Where(x => x.Instance.Applicable(session, ActionType.Attach, null) != Ruling.Denied).ToArray();
if (list.Length == 0) if (list.Length == 0)
@ -1068,12 +1070,13 @@ namespace Esyur.Net.IIP
SendReply(IIPPacket.IIPPacketAction.QueryLink, callback) SendReply(IIPPacket.IIPPacketAction.QueryLink, callback)
.AddUInt8Array(Codec.ComposeResourceArray(list, this, true)) .AddUInt8Array(Codec.ComposeResourceArray(list, this, true))
.Done(); .Done();
}
}; };
if (Server?.EntryPoint != null) if (Server?.EntryPoint != null)
Server.EntryPoint.Query(resourceLink, this).Then(queryCallback); Server.EntryPoint.Query(resourceLink, this).Then(queryCallback);
else else
Warehouse.Query(resourceLink).ContinueWith(x => queryCallback(x.Result)); Warehouse.Query(resourceLink).Then(x => queryCallback(x));
} }
void IIPRequestResourceAttribute(uint callback, uint resourceId) void IIPRequestResourceAttribute(uint callback, uint resourceId)

View File

@ -176,6 +176,8 @@ namespace Esyur.Net.Sockets
//lock (receiveNetworkBuffer.SyncLock) //lock (receiveNetworkBuffer.SyncLock)
// Console.WriteLine(e. + " " + e.BytesTransferred);
receiveNetworkBuffer.Write(receiveBuffer, 0, (uint)e.BytesTransferred); receiveNetworkBuffer.Write(receiveBuffer, 0, (uint)e.BytesTransferred);
//Console.WriteLine("TC IN: " + (uint)e.BytesTransferred + " " + DC.ToHex(receiveBuffer, 0, (uint)e.BytesTransferred)); //Console.WriteLine("TC IN: " + (uint)e.BytesTransferred + " " + DC.ToHex(receiveBuffer, 0, (uint)e.BytesTransferred));

View File

@ -297,7 +297,7 @@ namespace Esyur.Resource
public static async Task<IResource[]> Query(string path) public static async AsyncReply<IResource[]> Query(string path)
{ {
var rt = new AsyncReply<IResource[]>(); var rt = new AsyncReply<IResource[]>();
@ -386,11 +386,11 @@ namespace Esyur.Resource
} }
Query(path).ContinueWith(rs => Query(path).Then(rs =>
{ {
// rt.TriggerError(new Exception()); // rt.TriggerError(new Exception());
if (rs.Result != null && rs.Result.Length > 0) if (rs != null && rs.Length > 0)
rt.Trigger(rs.Result[0]); rt.Trigger(rs.First());
else else
rt.Trigger(null); rt.Trigger(null);
}); });