diff --git a/Esyur/Esyur.csproj b/Esyur/Esyur.csproj index c2678eb..7e8bbe0 100644 --- a/Esyur/Esyur.csproj +++ b/Esyur/Esyur.csproj @@ -7,7 +7,7 @@ https://github.com/Esyur/Esyur-dotnet/blob/master/LICENSE http://www.esyur.com true - 1.4.2 + 1.4.3 https://github.com/esyur/esyur-dotnet Ahmed Kh. Zamil 1.3.1.0 diff --git a/Esyur/Net/IIP/DistributedConnection.cs b/Esyur/Net/IIP/DistributedConnection.cs index a696e3f..cabe6f1 100644 --- a/Esyur/Net/IIP/DistributedConnection.cs +++ b/Esyur/Net/IIP/DistributedConnection.cs @@ -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; diff --git a/Esyur/Net/IIP/DistributedConnectionProtocol.cs b/Esyur/Net/IIP/DistributedConnectionProtocol.cs index d256c10..db4ae78 100644 --- a/Esyur/Net/IIP/DistributedConnectionProtocol.cs +++ b/Esyur/Net/IIP/DistributedConnectionProtocol.cs @@ -1058,22 +1058,25 @@ namespace Esyur.Net.IIP Action queryCallback = (r) => { - //if (r != null) - //{ - var list = r.Where(x => x.Instance.Applicable(session, ActionType.Attach, null) != Ruling.Denied).ToArray(); - - if (list.Length == 0) + if (r == null) SendError(ErrorType.Management, callback, (ushort)ExceptionCode.ResourceNotFound); else - SendReply(IIPPacket.IIPPacketAction.QueryLink, callback) - .AddUInt8Array(Codec.ComposeResourceArray(list, this, true)) - .Done(); + { + var list = r.Where(x => x.Instance.Applicable(session, ActionType.Attach, null) != Ruling.Denied).ToArray(); + + if (list.Length == 0) + SendError(ErrorType.Management, callback, (ushort)ExceptionCode.ResourceNotFound); + else + 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) diff --git a/Esyur/Net/Sockets/TCPSocket.cs b/Esyur/Net/Sockets/TCPSocket.cs index a42fdb8..912a5d4 100644 --- a/Esyur/Net/Sockets/TCPSocket.cs +++ b/Esyur/Net/Sockets/TCPSocket.cs @@ -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)); diff --git a/Esyur/Resource/Warehouse.cs b/Esyur/Resource/Warehouse.cs index ba0df24..774a4d0 100644 --- a/Esyur/Resource/Warehouse.cs +++ b/Esyur/Resource/Warehouse.cs @@ -297,7 +297,7 @@ namespace Esyur.Resource - public static async Task Query(string path) + public static async AsyncReply Query(string path) { var rt = new AsyncReply(); @@ -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); });