mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2025-05-06 11:32:59 +00:00
IIP3.5
This commit is contained in:
parent
4cfad2a242
commit
e790fe18e5
@ -292,7 +292,7 @@ namespace Esiur.Net.IIP
|
|||||||
queue.Then((x) =>
|
queue.Then((x) =>
|
||||||
{
|
{
|
||||||
if (x.Type == DistributedResourceQueueItem.DistributedResourceQueueItemType.Event)
|
if (x.Type == DistributedResourceQueueItem.DistributedResourceQueueItemType.Event)
|
||||||
x.Resource._EmitEventByIndex(x.Index, (object[])x.Value);
|
x.Resource._EmitEventByIndex(x.Index, x.Value);
|
||||||
else
|
else
|
||||||
x.Resource._UpdatePropertyByIndex(x.Index, x.Value);
|
x.Resource._UpdatePropertyByIndex(x.Index, x.Value);
|
||||||
});
|
});
|
||||||
@ -895,7 +895,7 @@ namespace Esiur.Net.IIP
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
this.Socket.Unhold();
|
this.Socket?.Unhold();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -344,7 +344,7 @@ namespace Esiur.Net.IIP
|
|||||||
var item = new AsyncReply<DistributedResourceQueueItem>();
|
var item = new AsyncReply<DistributedResourceQueueItem>();
|
||||||
queue.Add(item);
|
queue.Add(item);
|
||||||
|
|
||||||
Codec.ParseVarArray(content, this).Then((arguments) =>
|
Codec.Parse(content, 0, this).Then((arguments) =>
|
||||||
{
|
{
|
||||||
var et = r.Instance.Template.GetEventTemplateByIndex(index);
|
var et = r.Instance.Template.GetEventTemplateByIndex(index);
|
||||||
if (et != null)
|
if (et != null)
|
||||||
@ -1286,18 +1286,21 @@ namespace Esiur.Net.IIP
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// ft found, fi not found, this should never happen
|
// ft found, fi not found, this should never happen
|
||||||
|
SendError(ErrorType.Management, callback, (ushort)ExceptionCode.MethodNotFound);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// no function at this index
|
// no function at this index
|
||||||
|
SendError(ErrorType.Management, callback, (ushort)ExceptionCode.MethodNotFound);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// no resource with this id
|
// no resource with this id
|
||||||
|
SendError(ErrorType.Management, callback, (ushort)ExceptionCode.ResourceNotFound);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1445,18 +1448,23 @@ namespace Esiur.Net.IIP
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// ft found, fi not found, this should never happen
|
// ft found, fi not found, this should never happen
|
||||||
|
SendError(ErrorType.Management, callback, (ushort)ExceptionCode.MethodNotFound);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// no function at this index
|
// no function at this index
|
||||||
|
SendError(ErrorType.Management, callback, (ushort)ExceptionCode.MethodNotFound);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// no resource with this id
|
// no resource with this id
|
||||||
|
SendError(ErrorType.Management, callback, (ushort)ExceptionCode.ResourceNotFound);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -2298,7 +2306,7 @@ namespace Esiur.Net.IIP
|
|||||||
|
|
||||||
// private void Instance_EventOccurred(IResource resource, string name, string[] users, DistributedConnection[] connections, object[] args)
|
// private void Instance_EventOccurred(IResource resource, string name, string[] users, DistributedConnection[] connections, object[] args)
|
||||||
|
|
||||||
private void Instance_CustomEventOccurred(IResource resource, object issuer, Func<Session, bool> receivers, string name, object[] args)
|
private void Instance_CustomEventOccurred(IResource resource, object issuer, Func<Session, bool> receivers, string name, object args)
|
||||||
{
|
{
|
||||||
var et = resource.Instance.Template.GetEventTemplateByName(name);
|
var et = resource.Instance.Template.GetEventTemplateByName(name);
|
||||||
|
|
||||||
@ -2315,11 +2323,11 @@ namespace Esiur.Net.IIP
|
|||||||
SendEvent(IIPPacket.IIPPacketEvent.EventOccurred)
|
SendEvent(IIPPacket.IIPPacketEvent.EventOccurred)
|
||||||
.AddUInt32(resource.Instance.Id)
|
.AddUInt32(resource.Instance.Id)
|
||||||
.AddUInt8((byte)et.Index)
|
.AddUInt8((byte)et.Index)
|
||||||
.AddUInt8Array(Codec.ComposeVarArray(args, this, true))
|
.AddUInt8Array(Codec.Compose(args, this, true))
|
||||||
.Done();
|
.Done();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Instance_EventOccurred(IResource resource, string name, object[] args)
|
private void Instance_EventOccurred(IResource resource, string name, object args)
|
||||||
{
|
{
|
||||||
var et = resource.Instance.Template.GetEventTemplateByName(name);
|
var et = resource.Instance.Template.GetEventTemplateByName(name);
|
||||||
|
|
||||||
@ -2334,7 +2342,7 @@ namespace Esiur.Net.IIP
|
|||||||
SendEvent(IIPPacket.IIPPacketEvent.EventOccurred)
|
SendEvent(IIPPacket.IIPPacketEvent.EventOccurred)
|
||||||
.AddUInt32(resource.Instance.Id)
|
.AddUInt32(resource.Instance.Id)
|
||||||
.AddUInt8((byte)et.Index)
|
.AddUInt8((byte)et.Index)
|
||||||
.AddUInt8Array(Codec.ComposeVarArray(args, this, true))
|
.AddUInt8Array(Codec.Compose(args, this, true))
|
||||||
.Done();
|
.Done();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,7 @@ namespace Esiur.Net.IIP
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void _EmitEventByIndex(byte index, object[] args)
|
internal void _EmitEventByIndex(byte index, object args)
|
||||||
{
|
{
|
||||||
var et = Instance.Template.GetEventTemplateByIndex(index);
|
var et = Instance.Template.GetEventTemplateByIndex(index);
|
||||||
events[index]?.Invoke(this, args);
|
events[index]?.Invoke(this, args);
|
||||||
|
@ -30,5 +30,5 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Esiur.Net.IIP
|
namespace Esiur.Net.IIP
|
||||||
{
|
{
|
||||||
public delegate void DistributedResourceEvent(DistributedResource sender, params object[] arguments);
|
public delegate void DistributedResourceEvent(DistributedResource sender, object arguments);
|
||||||
}
|
}
|
||||||
|
@ -300,7 +300,8 @@ namespace Esiur.Net.Packets
|
|||||||
|
|
||||||
offset += cl;
|
offset += cl;
|
||||||
}
|
}
|
||||||
else if (Event == IIPPacketEvent.PropertyUpdated)
|
else if (Event == IIPPacketEvent.PropertyUpdated
|
||||||
|
|| Event == IIPPacketEvent.EventOccurred)
|
||||||
{
|
{
|
||||||
if (NotEnough(offset, ends, 2))
|
if (NotEnough(offset, ends, 2))
|
||||||
return -dataLengthNeeded;
|
return -dataLengthNeeded;
|
||||||
@ -333,23 +334,23 @@ namespace Esiur.Net.Packets
|
|||||||
offset += (uint)size;
|
offset += (uint)size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Event == IIPPacketEvent.EventOccurred)
|
//else if (Event == IIPPacketEvent.EventOccurred)
|
||||||
{
|
//{
|
||||||
if (NotEnough(offset, ends, 5))
|
// if (NotEnough(offset, ends, 5))
|
||||||
return -dataLengthNeeded;
|
// return -dataLengthNeeded;
|
||||||
|
|
||||||
MethodIndex = data[offset++];
|
// MethodIndex = data[offset++];
|
||||||
|
|
||||||
var cl = data.GetUInt32(offset);
|
// var cl = data.GetUInt32(offset);
|
||||||
offset += 4;
|
// offset += 4;
|
||||||
|
|
||||||
if (NotEnough(offset, ends, cl))
|
// if (NotEnough(offset, ends, cl))
|
||||||
return -dataLengthNeeded;
|
// return -dataLengthNeeded;
|
||||||
|
|
||||||
Content = data.Clip(offset, cl);
|
// Content = data.Clip(offset, cl);
|
||||||
offset += cl;
|
// offset += cl;
|
||||||
|
|
||||||
}
|
//}
|
||||||
// Attribute
|
// Attribute
|
||||||
else if (Event == IIPPacketEvent.AttributesUpdated)
|
else if (Event == IIPPacketEvent.AttributesUpdated)
|
||||||
{
|
{
|
||||||
|
@ -31,9 +31,9 @@ namespace Esiur.Resource
|
|||||||
|
|
||||||
|
|
||||||
public delegate void ResourceModifiedEvent(IResource resource, string propertyName, object newValue);
|
public delegate void ResourceModifiedEvent(IResource resource, string propertyName, object newValue);
|
||||||
public delegate void ResourceEventOccurredEvent(IResource resource, string eventName, object[] args);
|
public delegate void ResourceEventOccurredEvent(IResource resource, string eventName, object args);
|
||||||
|
|
||||||
public delegate void CustomResourceEventOccurredEvent(IResource resource, object issuer, Func<Session, bool> receivers, string eventName, object[] args);
|
public delegate void CustomResourceEventOccurredEvent(IResource resource, object issuer, Func<Session, bool> receivers, string eventName, object args);
|
||||||
|
|
||||||
public delegate void ResourceDestroyedEvent(IResource resource);
|
public delegate void ResourceDestroyedEvent(IResource resource);
|
||||||
|
|
||||||
@ -589,7 +589,7 @@ namespace Esiur.Resource
|
|||||||
|
|
||||||
// internal void EmitResourceEvent(string name, string[] users, DistributedConnection[] connections, object[] args)
|
// internal void EmitResourceEvent(string name, string[] users, DistributedConnection[] connections, object[] args)
|
||||||
|
|
||||||
internal void EmitCustomResourceEvent(object issuer, Func<Session, bool> receivers, string name, object[] args)
|
internal void EmitCustomResourceEvent(object issuer, Func<Session, bool> receivers, string name, object args)
|
||||||
{
|
{
|
||||||
IResource res;
|
IResource res;
|
||||||
if (this.resource.TryGetTarget(out res))
|
if (this.resource.TryGetTarget(out res))
|
||||||
@ -598,7 +598,7 @@ namespace Esiur.Resource
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void EmitResourceEvent(string name, object[] args)
|
internal void EmitResourceEvent(string name, object args)
|
||||||
{
|
{
|
||||||
IResource res;
|
IResource res;
|
||||||
if (this.resource.TryGetTarget(out res))
|
if (this.resource.TryGetTarget(out res))
|
||||||
|
@ -33,12 +33,12 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Esiur.Resource
|
namespace Esiur.Resource
|
||||||
{
|
{
|
||||||
public delegate void ResourceEventHanlder(params object[] args);
|
public delegate void ResourceEventHanlder(object args);
|
||||||
// public delegate void CustomUsersEventHanlder(string[] usernames, params object[] args);
|
// public delegate void CustomUsersEventHanlder(string[] usernames, params object[] args);
|
||||||
//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(object issuer, Func<Session, bool> receivers, params object[] args);// object issuer, Session[] receivers, params object[] args);
|
public delegate void CustomResourceEventHanlder(object issuer, Func<Session, bool> receivers, object args);// 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);
|
||||||
|
|
||||||
|
@ -27,10 +27,10 @@ namespace Esiur.Resource.Template
|
|||||||
var exp = DC.ToBytes(Expansion);
|
var exp = DC.ToBytes(Expansion);
|
||||||
return new BinaryList()
|
return new BinaryList()
|
||||||
.AddUInt8(0x50)
|
.AddUInt8(0x50)
|
||||||
.AddInt32(exp.Length)
|
|
||||||
.AddUInt8Array(exp)
|
|
||||||
.AddUInt8((byte)name.Length)
|
.AddUInt8((byte)name.Length)
|
||||||
.AddUInt8Array(name)
|
.AddUInt8Array(name)
|
||||||
|
.AddInt32(exp.Length)
|
||||||
|
.AddUInt8Array(exp)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user