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:
parent
f66a809836
commit
128972bb74
@ -7,7 +7,7 @@
|
||||
<PackageLicenseUrl>https://github.com/Esyur/Esyur-dotnet/blob/master/LICENSE</PackageLicenseUrl>
|
||||
<PackageProjectUrl>http://www.esyur.com</PackageProjectUrl>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Version>1.4.2</Version>
|
||||
<Version>1.4.3</Version>
|
||||
<RepositoryUrl>https://github.com/esyur/esyur-dotnet</RepositoryUrl>
|
||||
<Authors>Ahmed Kh. Zamil</Authors>
|
||||
<AssemblyVersion>1.3.1.0</AssemblyVersion>
|
||||
|
@ -798,13 +798,12 @@ namespace Esyur.Net.IIP
|
||||
if (Instance.Attributes.ContainsKey("username")
|
||||
&& 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
|
||||
|
||||
var host = Instance.Name.Split(':');
|
||||
|
||||
var address = host[0];// hostname.Split(':')[0];
|
||||
var port = ushort.Parse(host[1]);// hostname.Split(':')[1]);
|
||||
var address = host[0];
|
||||
var port = ushort.Parse(host[1]);
|
||||
var username = Instance.Attributes["username"].ToString();
|
||||
|
||||
var domain = Instance.Attributes.ContainsKey("domain") ? Instance.Attributes["domain"].ToString() : address;
|
||||
|
@ -1058,8 +1058,10 @@ namespace Esyur.Net.IIP
|
||||
|
||||
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();
|
||||
|
||||
if (list.Length == 0)
|
||||
@ -1068,12 +1070,13 @@ namespace Esyur.Net.IIP
|
||||
SendReply(IIPPacket.IIPPacketAction.QueryLink, callback)
|
||||
.AddUInt8Array(Codec.ComposeResourceArray(list, this, true))
|
||||
.Done();
|
||||
}
|
||||
};
|
||||
|
||||
if (Server?.EntryPoint != null)
|
||||
Server.EntryPoint.Query(resourceLink, this).Then(queryCallback);
|
||||
else
|
||||
Warehouse.Query(resourceLink).ContinueWith(x => queryCallback(x.Result));
|
||||
Warehouse.Query(resourceLink).Then(x => queryCallback(x));
|
||||
}
|
||||
|
||||
void IIPRequestResourceAttribute(uint callback, uint resourceId)
|
||||
|
@ -176,6 +176,8 @@ namespace Esyur.Net.Sockets
|
||||
|
||||
|
||||
//lock (receiveNetworkBuffer.SyncLock)
|
||||
// Console.WriteLine(e. + " " + e.BytesTransferred);
|
||||
|
||||
receiveNetworkBuffer.Write(receiveBuffer, 0, (uint)e.BytesTransferred);
|
||||
|
||||
//Console.WriteLine("TC IN: " + (uint)e.BytesTransferred + " " + DC.ToHex(receiveBuffer, 0, (uint)e.BytesTransferred));
|
||||
|
@ -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[]>();
|
||||
|
||||
@ -386,11 +386,11 @@ namespace Esyur.Resource
|
||||
}
|
||||
|
||||
|
||||
Query(path).ContinueWith(rs =>
|
||||
Query(path).Then(rs =>
|
||||
{
|
||||
// rt.TriggerError(new Exception());
|
||||
if (rs.Result != null && rs.Result.Length > 0)
|
||||
rt.Trigger(rs.Result[0]);
|
||||
if (rs != null && rs.Length > 0)
|
||||
rt.Trigger(rs.First());
|
||||
else
|
||||
rt.Trigger(null);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user