2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-06-26 21:13:13 +00:00

async put

This commit is contained in:
2021-02-20 21:55:11 +03:00
parent 7c707637de
commit 4cfad2a242
6 changed files with 58 additions and 47 deletions

View File

@ -759,12 +759,18 @@ namespace Esiur.Net.IIP
.Done();
ready = true;
Warehouse.Put(this, this.LocalUsername, null, Server);
Warehouse.Put(this, this.LocalUsername, null, Server).Then(x =>
{
openReply?.Trigger(true);
OnReady?.Invoke(this);
openReply?.Trigger(true);
OnReady?.Invoke(this);
Server?.Membership.Login(session);
}).Error(x=>
{
openReply?.TriggerError(x);
});
Server?.Membership.Login(session);
//Global.Log("auth", LogType.Warning, "U:" + RemoteUsername + " IP:" + Socket.RemoteEndPoint.Address.ToString() + " S:AUTH");
@ -835,10 +841,12 @@ namespace Esiur.Net.IIP
ready = true;
// put it in the warehouse
Warehouse.Put(this, this.LocalUsername, null, Server);
Warehouse.Put(this, this.LocalUsername, null, Server).Then(x =>
{
openReply?.Trigger(true);
OnReady?.Invoke(this);
openReply?.Trigger(true);
OnReady?.Invoke(this);
}).Error(x=> openReply?.TriggerError(x));
}
}
@ -945,7 +953,7 @@ namespace Esiur.Net.IIP
}
}
return new AsyncReply<bool>();
return new AsyncReply<bool>(true);
}

View File

@ -770,11 +770,16 @@ namespace Esiur.Net.IIP
// create the resource
var resource = Activator.CreateInstance(type, args) as IResource;
Warehouse.Put(resource, name, store as IStore, parent);
Warehouse.Put(resource, name, store as IStore, parent).Then(ok =>
{
SendReply(IIPPacket.IIPPacketAction.CreateResource, callback)
.AddUInt32(resource.Instance.Id)
.Done();
SendReply(IIPPacket.IIPPacketAction.CreateResource, callback)
.AddUInt32(resource.Instance.Id)
.Done();
}).Error(x =>
{
SendError(ErrorType.Exception, callback, (ushort)ExceptionCode.AddToStoreFailed);
});
});
});
@ -1959,14 +1964,27 @@ namespace Esiur.Net.IIP
{
// ClassId, ResourceAge, ResourceLink, Content
if (resource == null)
Warehouse.Put(dr, id.ToString(), this, null, tmp);
Codec.ParsePropertyValueArray((byte[])rt[3], this).Then((ar) =>
{
dr._Attach(ar);
resourceRequests.Remove(id);
reply.Trigger(dr);
});
Warehouse.Put(dr, id.ToString(), this, null, tmp).Then((ok) =>
{
Codec.ParsePropertyValueArray((byte[])rt[3], this).Then((ar) =>
{
dr._Attach(ar);
resourceRequests.Remove(id);
reply.Trigger(dr);
});
}).Error(ex=>reply.TriggerError(ex));
}
else
{
Codec.ParsePropertyValueArray((byte[])rt[3], this).Then((ar) =>
{
dr._Attach(ar);
resourceRequests.Remove(id);
reply.Trigger(dr);
}).Error(ex=>reply.TriggerError(ex));
}
}).Error((ex) =>
{
reply.TriggerError(ex);