2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-09-13 12:43:17 +00:00
This commit is contained in:
2025-08-11 23:08:16 +03:00
parent acfb6af27a
commit 531770820f
10 changed files with 283 additions and 328 deletions

View File

@@ -17,9 +17,9 @@ public class IIPoHTTP : HTTPFilter
if (sender.Request.URL != "iip") if (sender.Request.URL != "iip")
return new AsyncReply<bool>(false); return new AsyncReply<bool>(false);
IIPPacketAction action = (IIPPacketAction)Convert.ToByte(sender.Request.Query["a"]); IIPPacketRequest action = (IIPPacketRequest)Convert.ToByte(sender.Request.Query["a"]);
if (action == IIPPacketAction.QueryLink) if (action == IIPPacketRequest.QueryLink)
{ {
EntryPoint.Query(sender.Request.Query["l"], null).Then(x => EntryPoint.Query(sender.Request.Query["l"], null).Then(x =>
{ {

View File

@@ -372,7 +372,7 @@ public partial class DistributedConnection : NetworkConnection, IStore
lastKeepAliveSent = now; lastKeepAliveSent = now;
SendRequest(IIPPacketAction.KeepAlive) SendRequest(IIPPacketRequest.KeepAlive)
.AddDateTime(now) .AddDateTime(now)
.AddUInt32(interval) .AddUInt32(interval)
.Done() .Done()
@@ -463,63 +463,63 @@ public partial class DistributedConnection : NetworkConnection, IStore
switch (packet.Action) switch (packet.Action)
{ {
// Manage // Manage
case IIPPacketAction.AttachResource: case IIPPacketRequest.AttachResource:
IIPRequestAttachResource(packet.CallbackId, packet.ResourceId); IIPRequestAttachResource(packet.CallbackId, packet.ResourceId);
break; break;
case IIPPacketAction.ReattachResource: case IIPPacketRequest.ReattachResource:
IIPRequestReattachResource(packet.CallbackId, packet.ResourceId, packet.ResourceAge); IIPRequestReattachResource(packet.CallbackId, packet.ResourceId, packet.ResourceAge);
break; break;
case IIPPacketAction.DetachResource: case IIPPacketRequest.DetachResource:
IIPRequestDetachResource(packet.CallbackId, packet.ResourceId); IIPRequestDetachResource(packet.CallbackId, packet.ResourceId);
break; break;
case IIPPacketAction.CreateResource: case IIPPacketRequest.CreateResource:
//@TODO : fix this //@TODO : fix this
//IIPRequestCreateResource(packet.CallbackId, packet.StoreId, packet.ResourceId, packet.Content); //IIPRequestCreateResource(packet.CallbackId, packet.StoreId, packet.ResourceId, packet.Content);
break; break;
case IIPPacketAction.DeleteResource: case IIPPacketRequest.DeleteResource:
IIPRequestDeleteResource(packet.CallbackId, packet.ResourceId); IIPRequestDeleteResource(packet.CallbackId, packet.ResourceId);
break; break;
case IIPPacketAction.AddChild: case IIPPacketRequest.AddChild:
IIPRequestAddChild(packet.CallbackId, packet.ResourceId, packet.ChildId); IIPRequestAddChild(packet.CallbackId, packet.ResourceId, packet.ChildId);
break; break;
case IIPPacketAction.RemoveChild: case IIPPacketRequest.RemoveChild:
IIPRequestRemoveChild(packet.CallbackId, packet.ResourceId, packet.ChildId); IIPRequestRemoveChild(packet.CallbackId, packet.ResourceId, packet.ChildId);
break; break;
case IIPPacketAction.RenameResource: case IIPPacketRequest.RenameResource:
IIPRequestRenameResource(packet.CallbackId, packet.ResourceId, packet.ResourceName); IIPRequestRenameResource(packet.CallbackId, packet.ResourceId, packet.ResourceName);
break; break;
// Inquire // Inquire
case IIPPacketAction.TemplateFromClassName: case IIPPacketRequest.TemplateFromClassName:
IIPRequestTemplateFromClassName(packet.CallbackId, packet.ClassName); IIPRequestTemplateFromClassName(packet.CallbackId, packet.ClassName);
break; break;
case IIPPacketAction.TemplateFromClassId: case IIPPacketRequest.TemplateFromClassId:
IIPRequestTemplateFromClassId(packet.CallbackId, packet.ClassId); IIPRequestTemplateFromClassId(packet.CallbackId, packet.ClassId);
break; break;
case IIPPacketAction.TemplateFromResourceId: case IIPPacketRequest.TemplateFromResourceId:
IIPRequestTemplateFromResourceId(packet.CallbackId, packet.ResourceId); IIPRequestTemplateFromResourceId(packet.CallbackId, packet.ResourceId);
break; break;
case IIPPacketAction.QueryLink: case IIPPacketRequest.QueryLink:
IIPRequestQueryResources(packet.CallbackId, packet.ResourceLink); IIPRequestQueryResources(packet.CallbackId, packet.ResourceLink);
break; break;
case IIPPacketAction.ResourceChildren: case IIPPacketRequest.ResourceChildren:
IIPRequestResourceChildren(packet.CallbackId, packet.ResourceId); IIPRequestResourceChildren(packet.CallbackId, packet.ResourceId);
break; break;
case IIPPacketAction.ResourceParents: case IIPPacketRequest.ResourceParents:
IIPRequestResourceParents(packet.CallbackId, packet.ResourceId); IIPRequestResourceParents(packet.CallbackId, packet.ResourceId);
break; break;
case IIPPacketAction.ResourceHistory: case IIPPacketRequest.ResourceHistory:
IIPRequestInquireResourceHistory(packet.CallbackId, packet.ResourceId, packet.FromDate, packet.ToDate); IIPRequestInquireResourceHistory(packet.CallbackId, packet.ResourceId, packet.FromDate, packet.ToDate);
break; break;
case IIPPacketAction.LinkTemplates: case IIPPacketRequest.LinkTemplates:
IIPRequestLinkTemplates(packet.CallbackId, packet.ResourceLink); IIPRequestLinkTemplates(packet.CallbackId, packet.ResourceLink);
break; break;
// Invoke // Invoke
case IIPPacketAction.InvokeFunction: case IIPPacketRequest.InvokeFunction:
IIPRequestInvokeFunction(packet.CallbackId, packet.ResourceId, packet.MethodIndex, (TransmissionType)packet.DataType, msg); IIPRequestInvokeFunction(packet.CallbackId, packet.ResourceId, packet.MethodIndex, (TransmissionType)packet.DataType, msg);
break; break;
@@ -534,53 +534,53 @@ public partial class DistributedConnection : NetworkConnection, IStore
// IIPRequestGetPropertyIfModifiedSince(packet.CallbackId, packet.ResourceId, packet.MethodIndex, packet.ResourceAge); // IIPRequestGetPropertyIfModifiedSince(packet.CallbackId, packet.ResourceId, packet.MethodIndex, packet.ResourceAge);
// break; // break;
case IIPPacketAction.Listen: case IIPPacketRequest.Listen:
IIPRequestListen(packet.CallbackId, packet.ResourceId, packet.MethodIndex); IIPRequestListen(packet.CallbackId, packet.ResourceId, packet.MethodIndex);
break; break;
case IIPPacketAction.Unlisten: case IIPPacketRequest.Unlisten:
IIPRequestUnlisten(packet.CallbackId, packet.ResourceId, packet.MethodIndex); IIPRequestUnlisten(packet.CallbackId, packet.ResourceId, packet.MethodIndex);
break; break;
case IIPPacketAction.SetProperty: case IIPPacketRequest.SetProperty:
IIPRequestSetProperty(packet.CallbackId, packet.ResourceId, packet.MethodIndex, (TransmissionType)packet.DataType, msg); IIPRequestSetProperty(packet.CallbackId, packet.ResourceId, packet.MethodIndex, (TransmissionType)packet.DataType, msg);
break; break;
// Attribute // Attribute
case IIPPacketAction.GetAllAttributes: case IIPPacketRequest.GetAllAttributes:
// @TODO : fix this // @TODO : fix this
//IIPRequestGetAttributes(packet.CallbackId, packet.ResourceId, packet.Content, true); //IIPRequestGetAttributes(packet.CallbackId, packet.ResourceId, packet.Content, true);
break; break;
case IIPPacketAction.UpdateAllAttributes: case IIPPacketRequest.UpdateAllAttributes:
// @TODO : fix this // @TODO : fix this
//IIPRequestUpdateAttributes(packet.CallbackId, packet.ResourceId, packet.Content, true); //IIPRequestUpdateAttributes(packet.CallbackId, packet.ResourceId, packet.Content, true);
break; break;
case IIPPacketAction.ClearAllAttributes: case IIPPacketRequest.ClearAllAttributes:
// @TODO : fix this // @TODO : fix this
//IIPRequestClearAttributes(packet.CallbackId, packet.ResourceId, packet.Content, true); //IIPRequestClearAttributes(packet.CallbackId, packet.ResourceId, packet.Content, true);
break; break;
case IIPPacketAction.GetAttributes: case IIPPacketRequest.GetAttributes:
// @TODO : fix this // @TODO : fix this
//IIPRequestGetAttributes(packet.CallbackId, packet.ResourceId, packet.Content, false); //IIPRequestGetAttributes(packet.CallbackId, packet.ResourceId, packet.Content, false);
break; break;
case IIPPacketAction.UpdateAttributes: case IIPPacketRequest.UpdateAttributes:
// @TODO : fix this // @TODO : fix this
//IIPRequestUpdateAttributes(packet.CallbackId, packet.ResourceId, packet.Content, false); //IIPRequestUpdateAttributes(packet.CallbackId, packet.ResourceId, packet.Content, false);
break; break;
case IIPPacketAction.ClearAttributes: case IIPPacketRequest.ClearAttributes:
// @TODO : fix this // @TODO : fix this
//IIPRequestClearAttributes(packet.CallbackId, packet.ResourceId, packet.Content, false); //IIPRequestClearAttributes(packet.CallbackId, packet.ResourceId, packet.Content, false);
break; break;
case IIPPacketAction.KeepAlive: case IIPPacketRequest.KeepAlive:
IIPRequestKeepAlive(packet.CallbackId, packet.CurrentTime, packet.Interval); IIPRequestKeepAlive(packet.CallbackId, packet.CurrentTime, packet.Interval);
break; break;
case IIPPacketAction.ProcedureCall: case IIPPacketRequest.ProcedureCall:
IIPRequestProcedureCall(packet.CallbackId, packet.Procedure, (TransmissionType)packet.DataType, msg); IIPRequestProcedureCall(packet.CallbackId, packet.Procedure, (TransmissionType)packet.DataType, msg);
break; break;
case IIPPacketAction.StaticCall: case IIPPacketRequest.StaticCall:
IIPRequestStaticCall(packet.CallbackId, packet.ClassId, packet.MethodIndex, (TransmissionType)packet.DataType, msg); IIPRequestStaticCall(packet.CallbackId, packet.ClassId, packet.MethodIndex, (TransmissionType)packet.DataType, msg);
break; break;
@@ -591,51 +591,51 @@ public partial class DistributedConnection : NetworkConnection, IStore
switch (packet.Action) switch (packet.Action)
{ {
// Manage // Manage
case IIPPacketAction.AttachResource: case IIPPacketRequest.AttachResource:
IIPReply(packet.CallbackId, packet.ClassId, packet.ResourceAge, packet.ResourceLink, packet.DataType, msg); IIPReply(packet.CallbackId, packet.ClassId, packet.ResourceAge, packet.ResourceLink, packet.DataType, msg);
break; break;
case IIPPacketAction.ReattachResource: case IIPPacketRequest.ReattachResource:
IIPReply(packet.CallbackId, packet.ResourceAge, packet.DataType, msg); IIPReply(packet.CallbackId, packet.ResourceAge, packet.DataType, msg);
break; break;
case IIPPacketAction.DetachResource: case IIPPacketRequest.DetachResource:
IIPReply(packet.CallbackId); IIPReply(packet.CallbackId);
break; break;
case IIPPacketAction.CreateResource: case IIPPacketRequest.CreateResource:
IIPReply(packet.CallbackId, packet.ResourceId); IIPReply(packet.CallbackId, packet.ResourceId);
break; break;
case IIPPacketAction.DeleteResource: case IIPPacketRequest.DeleteResource:
case IIPPacketAction.AddChild: case IIPPacketRequest.AddChild:
case IIPPacketAction.RemoveChild: case IIPPacketRequest.RemoveChild:
case IIPPacketAction.RenameResource: case IIPPacketRequest.RenameResource:
IIPReply(packet.CallbackId); IIPReply(packet.CallbackId);
break; break;
// Inquire // Inquire
case IIPPacketAction.TemplateFromClassName: case IIPPacketRequest.TemplateFromClassName:
case IIPPacketAction.TemplateFromClassId: case IIPPacketRequest.TemplateFromClassId:
case IIPPacketAction.TemplateFromResourceId: case IIPPacketRequest.TemplateFromResourceId:
var content = msg.Clip(packet.DataType.Value.Offset, (uint)packet.DataType.Value.ContentLength); var content = msg.Clip(packet.DataType.Value.Offset, (uint)packet.DataType.Value.ContentLength);
IIPReply(packet.CallbackId, TypeTemplate.Parse(content)); IIPReply(packet.CallbackId, TypeTemplate.Parse(content));
break; break;
case IIPPacketAction.QueryLink: case IIPPacketRequest.QueryLink:
case IIPPacketAction.ResourceChildren: case IIPPacketRequest.ResourceChildren:
case IIPPacketAction.ResourceParents: case IIPPacketRequest.ResourceParents:
case IIPPacketAction.ResourceHistory: case IIPPacketRequest.ResourceHistory:
case IIPPacketAction.LinkTemplates: case IIPPacketRequest.LinkTemplates:
IIPReply(packet.CallbackId, (TransmissionType)packet.DataType, msg);// packet.Content); IIPReply(packet.CallbackId, (TransmissionType)packet.DataType, msg);// packet.Content);
break; break;
// Invoke // Invoke
case IIPPacketAction.InvokeFunction: case IIPPacketRequest.InvokeFunction:
case IIPPacketAction.StaticCall: case IIPPacketRequest.StaticCall:
case IIPPacketAction.ProcedureCall: case IIPPacketRequest.ProcedureCall:
IIPReplyInvoke(packet.CallbackId, (TransmissionType)packet.DataType, msg);// packet.Content); IIPReplyInvoke(packet.CallbackId, (TransmissionType)packet.DataType, msg);// packet.Content);
break; break;
@@ -647,26 +647,26 @@ public partial class DistributedConnection : NetworkConnection, IStore
// IIPReply(packet.CallbackId, packet.Content); // IIPReply(packet.CallbackId, packet.Content);
// break; // break;
case IIPPacketAction.Listen: case IIPPacketRequest.Listen:
case IIPPacketAction.Unlisten: case IIPPacketRequest.Unlisten:
case IIPPacketAction.SetProperty: case IIPPacketRequest.SetProperty:
IIPReply(packet.CallbackId); IIPReply(packet.CallbackId);
break; break;
// Attribute // Attribute
case IIPPacketAction.GetAllAttributes: case IIPPacketRequest.GetAllAttributes:
case IIPPacketAction.GetAttributes: case IIPPacketRequest.GetAttributes:
IIPReply(packet.CallbackId, (TransmissionType)packet.DataType, msg);// packet.Content); IIPReply(packet.CallbackId, (TransmissionType)packet.DataType, msg);// packet.Content);
break; break;
case IIPPacketAction.UpdateAllAttributes: case IIPPacketRequest.UpdateAllAttributes:
case IIPPacketAction.UpdateAttributes: case IIPPacketRequest.UpdateAttributes:
case IIPPacketAction.ClearAllAttributes: case IIPPacketRequest.ClearAllAttributes:
case IIPPacketAction.ClearAttributes: case IIPPacketRequest.ClearAttributes:
IIPReply(packet.CallbackId); IIPReply(packet.CallbackId);
break; break;
case IIPPacketAction.KeepAlive: case IIPPacketRequest.KeepAlive:
IIPReply(packet.CallbackId, packet.CurrentTime, packet.Jitter); IIPReply(packet.CallbackId, packet.CurrentTime, packet.Jitter);
break; break;
} }
@@ -1653,7 +1653,7 @@ public partial class DistributedConnection : NetworkConnection, IStore
try try
{ {
var ar = await SendRequest(IIPPacketAction.QueryLink) var ar = await SendRequest(IIPPacketRequest.QueryLink)
.AddUInt16((ushort)link.Length) .AddUInt16((ushort)link.Length)
.AddUInt8Array(link) .AddUInt8Array(link)
.Done(); .Done();

View File

@@ -76,7 +76,7 @@ partial class DistributedConnection
/// <param name="action">Packet action.</param> /// <param name="action">Packet action.</param>
/// <param name="args">Arguments to send.</param> /// <param name="args">Arguments to send.</param>
/// <returns></returns> /// <returns></returns>
SendList SendRequest(IIPPacketAction action) SendList SendRequest(IIPPacketRequest action)
{ {
var reply = new AsyncReply<object[]>(); var reply = new AsyncReply<object[]>();
var c = callbackCounter++; // avoid thread racing var c = callbackCounter++; // avoid thread racing
@@ -102,7 +102,7 @@ partial class DistributedConnection
//uint maxcallerid = 0; //uint maxcallerid = 0;
internal SendList SendReply(IIPPacketAction action, uint callbackId) internal SendList SendReply(IIPPacketRequest action, uint callbackId)
{ {
return (SendList)SendParams().AddUInt8((byte)(0x80 | (byte)action)).AddUInt32(callbackId); return (SendList)SendParams().AddUInt8((byte)(0x80 | (byte)action)).AddUInt32(callbackId);
} }
@@ -118,7 +118,7 @@ partial class DistributedConnection
var c = callbackCounter++; var c = callbackCounter++;
requests.Add(c, reply); requests.Add(c, reply);
SendParams().AddUInt8((byte)(0x40 | (byte)IIPPacketAction.Listen)) SendParams().AddUInt8((byte)(0x40 | (byte)IIPPacketRequest.Listen))
.AddUInt32(c) .AddUInt32(c)
.AddUInt32(instanceId) .AddUInt32(instanceId)
.AddUInt8(index) .AddUInt8(index)
@@ -133,7 +133,7 @@ partial class DistributedConnection
var c = callbackCounter++; var c = callbackCounter++;
requests.Add(c, reply); requests.Add(c, reply);
SendParams().AddUInt8((byte)(0x40 | (byte)IIPPacketAction.Unlisten)) SendParams().AddUInt8((byte)(0x40 | (byte)IIPPacketRequest.Unlisten))
.AddUInt32(c) .AddUInt32(c)
.AddUInt32(instanceId) .AddUInt32(instanceId)
.AddUInt8(index) .AddUInt8(index)
@@ -152,7 +152,7 @@ partial class DistributedConnection
requests.Add(c, reply); requests.Add(c, reply);
SendParams().AddUInt8((byte)(0x40 | (byte)IIPPacketAction.StaticCall)) SendParams().AddUInt8((byte)(0x40 | (byte)IIPPacketRequest.StaticCall))
.AddUInt32(c) .AddUInt32(c)
.AddUUID(classId) .AddUUID(classId)
.AddUInt8(index) .AddUInt8(index)
@@ -180,7 +180,7 @@ partial class DistributedConnection
var callName = DC.ToBytes(procedureCall); var callName = DC.ToBytes(procedureCall);
SendParams().AddUInt8((byte)(0x40 | (byte)IIPPacketAction.ProcedureCall)) SendParams().AddUInt8((byte)(0x40 | (byte)IIPPacketRequest.ProcedureCall))
.AddUInt32(c) .AddUInt32(c)
.AddUInt16((ushort)callName.Length) .AddUInt16((ushort)callName.Length)
.AddUInt8Array(callName) .AddUInt8Array(callName)
@@ -198,7 +198,7 @@ partial class DistributedConnection
var c = callbackCounter++; var c = callbackCounter++;
requests.Add(c, reply); requests.Add(c, reply);
SendParams().AddUInt8((byte)(0x40 | (byte)IIPPacketAction.InvokeFunction)) SendParams().AddUInt8((byte)(0x40 | (byte)IIPPacketRequest.InvokeFunction))
.AddUInt32(c) .AddUInt32(c)
.AddUInt32(instanceId) .AddUInt32(instanceId)
.AddUInt8(index) .AddUInt8(index)
@@ -211,7 +211,7 @@ partial class DistributedConnection
{ {
var cv = Codec.Compose(value, this); var cv = Codec.Compose(value, this);
return SendRequest(IIPPacketAction.SetProperty) return SendRequest(IIPPacketRequest.SetProperty)
.AddUInt32(instanceId) .AddUInt32(instanceId)
.AddUInt8(index) .AddUInt8(index)
.AddUInt8Array(cv) .AddUInt8Array(cv)
@@ -237,7 +237,7 @@ partial class DistributedConnection
} }
if (sendDetach) if (sendDetach)
return SendRequest(IIPPacketAction.DetachResource) return SendRequest(IIPPacketRequest.DetachResource)
.AddUInt32(instanceId) .AddUInt32(instanceId)
.Done(); .Done();
@@ -576,7 +576,7 @@ partial class DistributedConnection
if (r is DistributedResource) if (r is DistributedResource)
{ {
// reply ok // reply ok
SendReply(IIPPacketAction.AttachResource, callback) SendReply(IIPPacketRequest.AttachResource, callback)
.AddUUID(r.Instance.Template.ClassId) .AddUUID(r.Instance.Template.ClassId)
.AddUInt64(r.Instance.Age) .AddUInt64(r.Instance.Age)
.AddUInt16((ushort)link.Length) .AddUInt16((ushort)link.Length)
@@ -588,7 +588,7 @@ partial class DistributedConnection
else else
{ {
// reply ok // reply ok
SendReply(IIPPacketAction.AttachResource, callback) SendReply(IIPPacketRequest.AttachResource, callback)
.AddUUID(r.Instance.Template.ClassId) .AddUUID(r.Instance.Template.ClassId)
.AddUInt64(r.Instance.Age) .AddUInt64(r.Instance.Age)
.AddUInt16((ushort)link.Length) .AddUInt16((ushort)link.Length)
@@ -713,7 +713,7 @@ partial class DistributedConnection
//r.Instance.Attributes.OnModified += Attributes_OnModified; //r.Instance.Attributes.OnModified += Attributes_OnModified;
// reply ok // reply ok
SendReply(IIPPacketAction.ReattachResource, callback) SendReply(IIPPacketRequest.ReattachResource, callback)
.AddUInt64(r.Instance.Age) .AddUInt64(r.Instance.Age)
.AddUInt8Array(Codec.Compose(r.Instance.Serialize(), this)) .AddUInt8Array(Codec.Compose(r.Instance.Serialize(), this))
.Done(); .Done();
@@ -742,7 +742,7 @@ partial class DistributedConnection
//attachedResources.Remove(res); //attachedResources.Remove(res);
// reply ok // reply ok
SendReply(IIPPacketAction.DetachResource, callback).Done(); SendReply(IIPPacketRequest.DetachResource, callback).Done();
} }
else else
{ {
@@ -869,7 +869,7 @@ partial class DistributedConnection
Warehouse.Put(name, resource, store as IStore, parent).Then(ok => Warehouse.Put(name, resource, store as IStore, parent).Then(ok =>
{ {
SendReply(IIPPacketAction.CreateResource, callback) SendReply(IIPPacketRequest.CreateResource, callback)
.AddUInt32(resource.Instance.Id) .AddUInt32(resource.Instance.Id)
.Done(); .Done();
@@ -902,7 +902,7 @@ partial class DistributedConnection
} }
if (Warehouse.Remove(r)) if (Warehouse.Remove(r))
SendReply(IIPPacketAction.DeleteResource, callback).Done(); SendReply(IIPPacketRequest.DeleteResource, callback).Done();
//SendParams((byte)0x84, callback); //SendParams((byte)0x84, callback);
else else
SendError(ErrorType.Management, callback, (ushort)ExceptionCode.DeleteFailed); SendError(ErrorType.Management, callback, (ushort)ExceptionCode.DeleteFailed);
@@ -934,7 +934,7 @@ partial class DistributedConnection
var st = r.Instance.GetAttributes(attrs); var st = r.Instance.GetAttributes(attrs);
if (st != null) if (st != null)
SendReply(all ? IIPPacketAction.GetAllAttributes : IIPPacketAction.GetAttributes, callback) SendReply(all ? IIPPacketRequest.GetAllAttributes : IIPPacketRequest.GetAttributes, callback)
.AddUInt8Array(Codec.Compose(st, this)) .AddUInt8Array(Codec.Compose(st, this))
.Done(); .Done();
else else
@@ -975,7 +975,7 @@ partial class DistributedConnection
parent.Instance.Store.AddChild(parent, child); parent.Instance.Store.AddChild(parent, child);
SendReply(IIPPacketAction.AddChild, callback).Done(); SendReply(IIPPacketRequest.AddChild, callback).Done();
//child.Instance.Parents //child.Instance.Parents
}); });
@@ -1014,7 +1014,7 @@ partial class DistributedConnection
parent.Instance.Store.RemoveChild(parent, child);// Children.Remove(child); parent.Instance.Store.RemoveChild(parent, child);// Children.Remove(child);
SendReply(IIPPacketAction.RemoveChild, callback).Done(); SendReply(IIPPacketRequest.RemoveChild, callback).Done();
//child.Instance.Parents //child.Instance.Parents
}); });
@@ -1039,7 +1039,7 @@ partial class DistributedConnection
resource.Instance.Name = name; resource.Instance.Name = name;
SendReply(IIPPacketAction.RenameResource, callback).Done(); SendReply(IIPPacketRequest.RenameResource, callback).Done();
}); });
} }
@@ -1055,7 +1055,7 @@ partial class DistributedConnection
resource.Instance.Children<IResource>().Then(children => resource.Instance.Children<IResource>().Then(children =>
{ {
SendReply(IIPPacketAction.ResourceChildren, callback) SendReply(IIPPacketRequest.ResourceChildren, callback)
.AddUInt8Array(Codec.Compose(children, this))// Codec.ComposeResourceArray(children, this, true)) .AddUInt8Array(Codec.Compose(children, this))// Codec.ComposeResourceArray(children, this, true))
.Done(); .Done();
@@ -1077,7 +1077,7 @@ partial class DistributedConnection
resource.Instance.Parents<IResource>().Then(parents => resource.Instance.Parents<IResource>().Then(parents =>
{ {
SendReply(IIPPacketAction.ResourceParents, callback) SendReply(IIPPacketRequest.ResourceParents, callback)
.AddUInt8Array(Codec.Compose(parents, this)) .AddUInt8Array(Codec.Compose(parents, this))
//.AddUInt8Array(Codec.ComposeResourceArray(parents, this, true)) //.AddUInt8Array(Codec.ComposeResourceArray(parents, this, true))
.Done(); .Done();
@@ -1109,7 +1109,7 @@ partial class DistributedConnection
attrs = attributes.GetStringArray(0, (uint)attributes.Length); attrs = attributes.GetStringArray(0, (uint)attributes.Length);
if (r.Instance.RemoveAttributes(attrs)) if (r.Instance.RemoveAttributes(attrs))
SendReply(all ? IIPPacketAction.ClearAllAttributes : IIPPacketAction.ClearAttributes, callback).Done(); SendReply(all ? IIPPacketRequest.ClearAllAttributes : IIPPacketRequest.ClearAttributes, callback).Done();
else else
SendError(ErrorType.Management, callback, (ushort)ExceptionCode.UpdateAttributeFailed); SendError(ErrorType.Management, callback, (ushort)ExceptionCode.UpdateAttributeFailed);
@@ -1136,7 +1136,7 @@ partial class DistributedConnection
DataDeserializer.TypedMapParser(attributes, 0, (uint)attributes.Length, this, null).Then(attrs => DataDeserializer.TypedMapParser(attributes, 0, (uint)attributes.Length, this, null).Then(attrs =>
{ {
if (r.Instance.SetAttributes((Map<string, object>)attrs, clearAttributes)) if (r.Instance.SetAttributes((Map<string, object>)attrs, clearAttributes))
SendReply(clearAttributes ? IIPPacketAction.ClearAllAttributes : IIPPacketAction.ClearAttributes, SendReply(clearAttributes ? IIPPacketRequest.ClearAllAttributes : IIPPacketRequest.ClearAttributes,
callback).Done(); callback).Done();
else else
SendError(ErrorType.Management, callback, (ushort)ExceptionCode.UpdateAttributeFailed); SendError(ErrorType.Management, callback, (ushort)ExceptionCode.UpdateAttributeFailed);
@@ -1175,7 +1175,7 @@ partial class DistributedConnection
} }
// digggg // digggg
SendReply(IIPPacketAction.LinkTemplates, callback) SendReply(IIPPacketRequest.LinkTemplates, callback)
//.AddInt32(msg.Length) //.AddInt32(msg.Length)
//.AddUInt8Array(msg.ToArray()) //.AddUInt8Array(msg.ToArray())
.AddUInt8Array(TransmissionType.Compose(TransmissionTypeIdentifier.RawData, msg.ToArray())) .AddUInt8Array(TransmissionType.Compose(TransmissionTypeIdentifier.RawData, msg.ToArray()))
@@ -1195,7 +1195,7 @@ partial class DistributedConnection
var t = Warehouse.GetTemplateByClassName(className); var t = Warehouse.GetTemplateByClassName(className);
if (t != null) if (t != null)
SendReply(IIPPacketAction.TemplateFromClassName, callback) SendReply(IIPPacketRequest.TemplateFromClassName, callback)
.AddUInt8Array(TransmissionType.Compose(TransmissionTypeIdentifier.RawData, t.Content)) .AddUInt8Array(TransmissionType.Compose(TransmissionTypeIdentifier.RawData, t.Content))
//.AddInt32(t.Content.Length) //.AddInt32(t.Content.Length)
//.AddUInt8Array(t.Content) //.AddUInt8Array(t.Content)
@@ -1212,7 +1212,7 @@ partial class DistributedConnection
var t = Warehouse.GetTemplateByClassId(classId); var t = Warehouse.GetTemplateByClassId(classId);
if (t != null) if (t != null)
SendReply(IIPPacketAction.TemplateFromClassId, callback) SendReply(IIPPacketRequest.TemplateFromClassId, callback)
.AddUInt8Array(TransmissionType.Compose(TransmissionTypeIdentifier.RawData, t.Content)) .AddUInt8Array(TransmissionType.Compose(TransmissionTypeIdentifier.RawData, t.Content))
//.AddInt32(t.Content.Length) //.AddInt32(t.Content.Length)
//.AddUInt8Array(t.Content) //.AddUInt8Array(t.Content)
@@ -1231,7 +1231,7 @@ partial class DistributedConnection
Warehouse.GetById(resourceId).Then((r) => Warehouse.GetById(resourceId).Then((r) =>
{ {
if (r != null) if (r != null)
SendReply(IIPPacketAction.TemplateFromResourceId, callback) SendReply(IIPPacketRequest.TemplateFromResourceId, callback)
.AddInt32(r.Instance.Template.Content.Length) .AddInt32(r.Instance.Template.Content.Length)
.AddUInt8Array(r.Instance.Template.Content) .AddUInt8Array(r.Instance.Template.Content)
.Done(); .Done();
@@ -1260,7 +1260,7 @@ partial class DistributedConnection
if (list.Length == 0) if (list.Length == 0)
SendError(ErrorType.Management, callback, (ushort)ExceptionCode.ResourceNotFound); SendError(ErrorType.Management, callback, (ushort)ExceptionCode.ResourceNotFound);
else else
SendReply(IIPPacketAction.QueryLink, callback) SendReply(IIPPacketRequest.QueryLink, callback)
.AddUInt8Array(Codec.Compose(list, this)) .AddUInt8Array(Codec.Compose(list, this))
//.AddUInt8Array(Codec.ComposeResourceArray(list, this, true)) //.AddUInt8Array(Codec.ComposeResourceArray(list, this, true))
.Done(); .Done();
@@ -1326,7 +1326,7 @@ partial class DistributedConnection
// return; // return;
//} //}
InvokeFunction(call.Value.Template, callback, arguments, IIPPacketAction.ProcedureCall, call.Value.Delegate.Target); InvokeFunction(call.Value.Template, callback, arguments, IIPPacketRequest.ProcedureCall, call.Value.Delegate.Target);
}).Error(x => }).Error(x =>
{ {
@@ -1379,7 +1379,7 @@ partial class DistributedConnection
// return; // return;
//} //}
InvokeFunction(ft, callback, arguments, IIPPacketAction.StaticCall, null); InvokeFunction(ft, callback, arguments, IIPPacketRequest.StaticCall, null);
}).Error(x => }).Error(x =>
{ {
@@ -1425,7 +1425,7 @@ partial class DistributedConnection
{ {
rt.Then(res => rt.Then(res =>
{ {
SendReply(IIPPacketAction.InvokeFunction, callback) SendReply(IIPPacketRequest.InvokeFunction, callback)
.AddUInt8Array(Codec.Compose(res, this)) .AddUInt8Array(Codec.Compose(res, this))
.Done(); .Done();
}); });
@@ -1456,7 +1456,7 @@ partial class DistributedConnection
return; return;
} }
InvokeFunction(ft, callback, arguments, IIPPacketAction.InvokeFunction, r); InvokeFunction(ft, callback, arguments, IIPPacketRequest.InvokeFunction, r);
} }
}); });
}); });
@@ -1464,7 +1464,7 @@ partial class DistributedConnection
void InvokeFunction(FunctionTemplate ft, uint callback, Map<byte, object> arguments, IIPPacketAction actionType, object target = null) void InvokeFunction(FunctionTemplate ft, uint callback, Map<byte, object> arguments, IIPPacketRequest actionType, object target = null)
{ {
// cast arguments // cast arguments
@@ -1629,7 +1629,7 @@ partial class DistributedConnection
{ {
(r as DistributedResource).Listen(et).Then(x => (r as DistributedResource).Listen(et).Then(x =>
{ {
SendReply(IIPPacketAction.Listen, callback).Done(); SendReply(IIPPacketRequest.Listen, callback).Done();
}).Error(x => SendError(ErrorType.Exception, callback, (ushort)ExceptionCode.GeneralFailure)); }).Error(x => SendError(ErrorType.Exception, callback, (ushort)ExceptionCode.GeneralFailure));
} }
else else
@@ -1650,7 +1650,7 @@ partial class DistributedConnection
subscriptions[r].Add(index); subscriptions[r].Add(index);
SendReply(IIPPacketAction.Listen, callback).Done(); SendReply(IIPPacketRequest.Listen, callback).Done();
} }
} }
} }
@@ -1683,7 +1683,7 @@ partial class DistributedConnection
{ {
(r as DistributedResource).Unlisten(et).Then(x => (r as DistributedResource).Unlisten(et).Then(x =>
{ {
SendReply(IIPPacketAction.Unlisten, callback).Done(); SendReply(IIPPacketRequest.Unlisten, callback).Done();
}).Error(x => SendError(ErrorType.Exception, callback, (ushort)ExceptionCode.GeneralFailure)); }).Error(x => SendError(ErrorType.Exception, callback, (ushort)ExceptionCode.GeneralFailure));
} }
else else
@@ -1704,7 +1704,7 @@ partial class DistributedConnection
subscriptions[r].Remove(index); subscriptions[r].Remove(index);
SendReply(IIPPacketAction.Unlisten, callback).Done(); SendReply(IIPPacketRequest.Unlisten, callback).Done();
} }
} }
} }
@@ -1797,7 +1797,7 @@ partial class DistributedConnection
}*/ }*/
SendReply(IIPPacketAction.ResourceHistory, callback) SendReply(IIPPacketRequest.ResourceHistory, callback)
.AddUInt8Array(history) .AddUInt8Array(history)
.Done(); .Done();
@@ -1874,7 +1874,7 @@ partial class DistributedConnection
// propagation // propagation
(r as DistributedResource)._Set(index, value).Then((x) => (r as DistributedResource)._Set(index, value).Then((x) =>
{ {
SendReply(IIPPacketAction.SetProperty, callback).Done(); SendReply(IIPPacketRequest.SetProperty, callback).Done();
}).Error(x => }).Error(x =>
{ {
SendError(x.Type, callback, (ushort)x.Code, x.Message); SendError(x.Type, callback, (ushort)x.Code, x.Message);
@@ -1925,7 +1925,7 @@ partial class DistributedConnection
{ {
pi.SetValue(r, value); pi.SetValue(r, value);
SendReply(IIPPacketAction.SetProperty, callback).Done(); SendReply(IIPPacketRequest.SetProperty, callback).Done();
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -2107,7 +2107,7 @@ partial class DistributedConnection
var reply = new AsyncReply<TypeTemplate>(); var reply = new AsyncReply<TypeTemplate>();
templateRequests.Add(classId, reply); templateRequests.Add(classId, reply);
SendRequest(IIPPacketAction.TemplateFromClassId) SendRequest(IIPPacketRequest.TemplateFromClassId)
.AddUUID(classId) .AddUUID(classId)
.Done() .Done()
.Then((rt) => .Then((rt) =>
@@ -2139,7 +2139,7 @@ partial class DistributedConnection
var classNameBytes = DC.ToBytes(className); var classNameBytes = DC.ToBytes(className);
SendRequest(IIPPacketAction.TemplateFromClassName) SendRequest(IIPPacketRequest.TemplateFromClassName)
.AddUInt8((byte)classNameBytes.Length) .AddUInt8((byte)classNameBytes.Length)
.AddUInt8Array(classNameBytes) .AddUInt8Array(classNameBytes)
.Done() .Done()
@@ -2233,7 +2233,7 @@ partial class DistributedConnection
var l = DC.ToBytes(link); var l = DC.ToBytes(link);
SendRequest(IIPPacketAction.LinkTemplates) SendRequest(IIPPacketRequest.LinkTemplates)
.AddUInt16((ushort)l.Length) .AddUInt16((ushort)l.Length)
.AddUInt8Array(l) .AddUInt8Array(l)
.Done() .Done()
@@ -2312,7 +2312,7 @@ partial class DistributedConnection
var reply = new AsyncReply<DistributedResource>(); var reply = new AsyncReply<DistributedResource>();
resourceRequests.Add(id, new DistributedResourceAttachRequestInfo(reply, newSequence)); resourceRequests.Add(id, new DistributedResourceAttachRequestInfo(reply, newSequence));
SendRequest(IIPPacketAction.AttachResource) SendRequest(IIPPacketRequest.AttachResource)
.AddUInt32(id) .AddUInt32(id)
.Done() .Done()
.Then((rt) => .Then((rt) =>
@@ -2415,7 +2415,7 @@ partial class DistributedConnection
{ {
var rt = new AsyncReply<IResource[]>(); var rt = new AsyncReply<IResource[]>();
SendRequest(IIPPacketAction.ResourceChildren) SendRequest(IIPPacketRequest.ResourceChildren)
.AddUInt32(resource.Instance.Id) .AddUInt32(resource.Instance.Id)
.Done() .Done()
.Then(ar => .Then(ar =>
@@ -2441,7 +2441,7 @@ partial class DistributedConnection
{ {
var rt = new AsyncReply<IResource[]>(); var rt = new AsyncReply<IResource[]>();
SendRequest(IIPPacketAction.ResourceParents) SendRequest(IIPPacketRequest.ResourceParents)
.AddUInt32(resource.Instance.Id) .AddUInt32(resource.Instance.Id)
.Done() .Done()
.Then(ar => .Then(ar =>
@@ -2467,7 +2467,7 @@ partial class DistributedConnection
var rt = new AsyncReply<bool>(); var rt = new AsyncReply<bool>();
if (attributes == null) if (attributes == null)
SendRequest(IIPPacketAction.ClearAllAttributes) SendRequest(IIPPacketRequest.ClearAllAttributes)
.AddUInt32(resource.Instance.Id) .AddUInt32(resource.Instance.Id)
.Done() .Done()
.Then(ar => rt.Trigger(true)) .Then(ar => rt.Trigger(true))
@@ -2475,7 +2475,7 @@ partial class DistributedConnection
else else
{ {
var attrs = DC.ToBytes(attributes); var attrs = DC.ToBytes(attributes);
SendRequest(IIPPacketAction.ClearAttributes) SendRequest(IIPPacketRequest.ClearAttributes)
.AddUInt32(resource.Instance.Id) .AddUInt32(resource.Instance.Id)
.AddInt32(attrs.Length) .AddInt32(attrs.Length)
.AddUInt8Array(attrs) .AddUInt8Array(attrs)
@@ -2491,7 +2491,7 @@ partial class DistributedConnection
{ {
var rt = new AsyncReply<bool>(); var rt = new AsyncReply<bool>();
SendRequest(clearAttributes ? IIPPacketAction.UpdateAllAttributes : IIPPacketAction.UpdateAttributes) SendRequest(clearAttributes ? IIPPacketRequest.UpdateAllAttributes : IIPPacketRequest.UpdateAttributes)
.AddUInt32(resource.Instance.Id) .AddUInt32(resource.Instance.Id)
//.AddUInt8Array(Codec.ComposeStructure(attributes, this, true, true, true)) //.AddUInt8Array(Codec.ComposeStructure(attributes, this, true, true, true))
.AddUInt8Array(Codec.Compose(attributes, this)) .AddUInt8Array(Codec.Compose(attributes, this))
@@ -2508,7 +2508,7 @@ partial class DistributedConnection
if (attributes == null) if (attributes == null)
{ {
SendRequest(IIPPacketAction.GetAllAttributes) SendRequest(IIPPacketRequest.GetAllAttributes)
.AddUInt32(resource.Instance.Id) .AddUInt32(resource.Instance.Id)
.Done() .Done()
.Then(ar => .Then(ar =>
@@ -2529,7 +2529,7 @@ partial class DistributedConnection
else else
{ {
var attrs = DC.ToBytes(attributes); var attrs = DC.ToBytes(attributes);
SendRequest(IIPPacketAction.GetAttributes) SendRequest(IIPPacketRequest.GetAttributes)
.AddUInt32(resource.Instance.Id) .AddUInt32(resource.Instance.Id)
.AddInt32(attrs.Length) .AddInt32(attrs.Length)
.AddUInt8Array(attrs) .AddUInt8Array(attrs)
@@ -2571,7 +2571,7 @@ partial class DistributedConnection
var reply = new AsyncReply<KeyList<PropertyTemplate, PropertyValue[]>>(); var reply = new AsyncReply<KeyList<PropertyTemplate, PropertyValue[]>>();
SendRequest(IIPPacketAction.ResourceHistory) SendRequest(IIPPacketRequest.ResourceHistory)
.AddUInt32(dr.DistributedResourceInstanceId) .AddUInt32(dr.DistributedResourceInstanceId)
.AddDateTime(fromDate) .AddDateTime(fromDate)
.AddDateTime(toDate) .AddDateTime(toDate)
@@ -2601,7 +2601,7 @@ partial class DistributedConnection
var str = DC.ToBytes(path); var str = DC.ToBytes(path);
var reply = new AsyncReply<IResource[]>(); var reply = new AsyncReply<IResource[]>();
SendRequest(IIPPacketAction.QueryLink) SendRequest(IIPPacketRequest.QueryLink)
.AddUInt16((ushort)str.Length) .AddUInt16((ushort)str.Length)
.AddUInt8Array(str) .AddUInt8Array(str)
.Done() .Done()
@@ -2647,7 +2647,7 @@ partial class DistributedConnection
pkt.InsertInt32(8, pkt.Length); pkt.InsertInt32(8, pkt.Length);
SendRequest(IIPPacketAction.CreateResource) SendRequest(IIPPacketRequest.CreateResource)
.AddUInt8Array(pkt.ToArray()) .AddUInt8Array(pkt.ToArray())
.Done() .Done()
.Then(args => .Then(args =>
@@ -2810,7 +2810,7 @@ partial class DistributedConnection
} }
SendParams() SendParams()
.AddUInt8((byte)(0x80 | (byte)IIPPacketAction.KeepAlive)) .AddUInt8((byte)(0x80 | (byte)IIPPacketRequest.KeepAlive))
.AddUInt32(callbackId) .AddUInt32(callbackId)
.AddDateTime(now) .AddDateTime(now)
.AddUInt32(jitter) .AddUInt32(jitter)

View File

@@ -37,103 +37,56 @@ class IIPPacket : Packet
public override string ToString() public override string ToString()
{ {
var rt = Command.ToString(); var rt = Method.ToString();
if (Command == IIPPacketCommand.Event) if (Method == IIPPacketMethod.Notification)
{ {
rt += " " + Event.ToString(); rt += " " + Notification.ToString();
//if (Event == IIPPacketEvent.AttributesUpdated)
// rt +=
} }
else if (Command == IIPPacketCommand.Request) else if (Method == IIPPacketMethod.Request)
{ {
rt += " " + Action.ToString(); rt += " " + Request.ToString();
if (Action == IIPPacketAction.AttachResource) }
{ else if (Method == IIPPacketMethod.Reply)
rt += " CID: " + CallbackId + " RID: " + ResourceId; {
} rt += " " + Reply.ToString();
} }
else if (Command == IIPPacketCommand.Reply)
rt += " " + Action.ToString();
else if (Command == IIPPacketCommand.Report)
rt += " " + Report.ToString();
return rt; return rt;
} }
public uint CallbackId { get; set; }
public IIPPacketReport Report
public IIPPacketMethod Method
{
get;
set;
}
public IIPPacketRequest Request
{
get;
set;
}
public IIPPacketReply Reply
{ {
get; get;
set; set;
} }
public IIPPacketCommand Command public byte Extention { get; set; }
{
get; public IIPPacketNotification Notification
set;
}
public IIPPacketAction Action
{ {
get; get;
set; set;
} }
public IIPPacketEvent Event
{
get;
set;
}
public IIPPacketCommand PreviousCommand
{
get;
set;
}
public IIPPacketAction PreviousAction
{
get;
set;
}
public IIPPacketEvent PreviousEvent
{
get;
set;
}
public TransmissionType? DataType { get; set; } public TransmissionType? DataType { get; set; }
public uint ResourceId { get; set; }
public uint NewResourceId { get; set; }
//public uint ParentId { get; set; }
public uint ChildId { get; set; }
public uint StoreId { get; set; }
public ulong ResourceAge { get; set; }
//public byte[] Content { get; set; }
public ushort ErrorCode { get; set; }
public string ErrorMessage { get; set; }
public string ClassName { get; set; }
public string ResourceLink { get; set; }
public string ResourceName { get; set; }
public UUID ClassId { get; set; }
public byte MethodIndex { get; set; }
public string MethodName { get; set; }
public uint CallbackId { get; set; }
public int ProgressValue { get; set; }
public int ProgressMax { get; set; }
public DateTime FromDate { get; set; }
public DateTime ToDate { get; set; }
public ulong FromAge { get; set; }
public ulong ToAge { get; set; }
public DateTime CurrentTime { get; set; }
public uint Interval { get; set; }
public uint Jitter { get; set; }
public string Procedure { get; set; }
private uint dataLengthNeeded; private uint dataLengthNeeded;
private uint originalOffset; private uint originalOffset;
@@ -163,23 +116,18 @@ class IIPPacket : Packet
if (NotEnough(offset, ends, 1)) if (NotEnough(offset, ends, 1))
return -dataLengthNeeded; return -dataLengthNeeded;
PreviousCommand = Command; var hasDTU = (data[offset] & 0x20) == 0x20;
Command = (IIPPacketCommand)(data[offset] >> 6); Method = (IIPPacketMethod)(data[offset] >> 6);
if (Command == IIPPacketCommand.Event) if (Method == IIPPacketMethod.Notification)
{ {
Event = (IIPPacketEvent)(data[offset++] & 0x3f); Notification = (IIPPacketNotification)(data[offset++] & 0x3f);
if (NotEnough(offset, ends, 4))
return -dataLengthNeeded;
ResourceId = data.GetUInt32(offset, Endian.Little);
offset += 4;
} }
else if (Command == IIPPacketCommand.Report) else if (Method == IIPPacketMethod.Request)
{ {
Report = (IIPPacketReport)(data[offset++] & 0x3f); Request = (IIPPacketRequest)(data[offset++] & 0x3f);
if (NotEnough(offset, ends, 4)) if (NotEnough(offset, ends, 4))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -187,10 +135,9 @@ class IIPPacket : Packet
CallbackId = data.GetUInt32(offset, Endian.Little); CallbackId = data.GetUInt32(offset, Endian.Little);
offset += 4; offset += 4;
} }
else else if (Method == IIPPacketMethod.Reply)
{ {
PreviousAction = Action; Reply = (IIPPacketReply)(data[offset++] & 0x3f);
Action = (IIPPacketAction)(data[offset++] & 0x3f);
if (NotEnough(offset, ends, 4)) if (NotEnough(offset, ends, 4))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -198,6 +145,10 @@ class IIPPacket : Packet
CallbackId = data.GetUInt32(offset, Endian.Little); CallbackId = data.GetUInt32(offset, Endian.Little);
offset += 4; offset += 4;
} }
else if (Method == IIPPacketMethod.Extension)
{
Extention = (byte)(data[offset++] & 0x3f);
}
if (Command == IIPPacketCommand.Event) if (Command == IIPPacketCommand.Event)
{ {
@@ -299,7 +250,7 @@ class IIPPacket : Packet
} }
else if (Command == IIPPacketCommand.Request) else if (Command == IIPPacketCommand.Request)
{ {
if (Action == IIPPacketAction.AttachResource) if (Action == IIPPacketRequest.AttachResource)
{ {
if (NotEnough(offset, ends, 4)) if (NotEnough(offset, ends, 4))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -307,7 +258,7 @@ class IIPPacket : Packet
ResourceId = data.GetUInt32(offset, Endian.Little); ResourceId = data.GetUInt32(offset, Endian.Little);
offset += 4; offset += 4;
} }
else if (Action == IIPPacketAction.ReattachResource) else if (Action == IIPPacketRequest.ReattachResource)
{ {
if (NotEnough(offset, ends, 12)) if (NotEnough(offset, ends, 12))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -319,7 +270,7 @@ class IIPPacket : Packet
offset += 8; offset += 8;
} }
else if (Action == IIPPacketAction.DetachResource) else if (Action == IIPPacketRequest.DetachResource)
{ {
if (NotEnough(offset, ends, 4)) if (NotEnough(offset, ends, 4))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -328,7 +279,7 @@ class IIPPacket : Packet
offset += 4; offset += 4;
} }
else if (Action == IIPPacketAction.CreateResource) else if (Action == IIPPacketRequest.CreateResource)
{ {
if (NotEnough(offset, ends, 12)) if (NotEnough(offset, ends, 12))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -347,7 +298,7 @@ class IIPPacket : Packet
// @TODO: fix this // @TODO: fix this
//this.Content = data.Clip(offset, cl); //this.Content = data.Clip(offset, cl);
} }
else if (Action == IIPPacketAction.DeleteResource) else if (Action == IIPPacketRequest.DeleteResource)
{ {
if (NotEnough(offset, ends, 4)) if (NotEnough(offset, ends, 4))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -356,8 +307,8 @@ class IIPPacket : Packet
offset += 4; offset += 4;
} }
else if (Action == IIPPacketAction.AddChild else if (Action == IIPPacketRequest.AddChild
|| Action == IIPPacketAction.RemoveChild) || Action == IIPPacketRequest.RemoveChild)
{ {
if (NotEnough(offset, ends, 8)) if (NotEnough(offset, ends, 8))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -367,7 +318,7 @@ class IIPPacket : Packet
ChildId = data.GetUInt32(offset, Endian.Little); ChildId = data.GetUInt32(offset, Endian.Little);
offset += 4; offset += 4;
} }
else if (Action == IIPPacketAction.RenameResource) else if (Action == IIPPacketRequest.RenameResource)
{ {
if (NotEnough(offset, ends, 6)) if (NotEnough(offset, ends, 6))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -384,7 +335,7 @@ class IIPPacket : Packet
//Content = data.Clip(offset, cl); //Content = data.Clip(offset, cl);
offset += cl; offset += cl;
} }
else if (Action == IIPPacketAction.TemplateFromClassName) else if (Action == IIPPacketRequest.TemplateFromClassName)
{ {
if (NotEnough(offset, ends, 1)) if (NotEnough(offset, ends, 1))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -398,7 +349,7 @@ class IIPPacket : Packet
offset += cl; offset += cl;
} }
else if (Action == IIPPacketAction.TemplateFromClassId) else if (Action == IIPPacketRequest.TemplateFromClassId)
{ {
if (NotEnough(offset, ends, 16)) if (NotEnough(offset, ends, 16))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -407,7 +358,7 @@ class IIPPacket : Packet
offset += 16; offset += 16;
} }
else if (Action == IIPPacketAction.TemplateFromResourceId) else if (Action == IIPPacketRequest.TemplateFromResourceId)
{ {
if (NotEnough(offset, ends, 4)) if (NotEnough(offset, ends, 4))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -415,8 +366,8 @@ class IIPPacket : Packet
ResourceId = data.GetUInt32(offset, Endian.Little); ResourceId = data.GetUInt32(offset, Endian.Little);
offset += 4; offset += 4;
} }
else if (Action == IIPPacketAction.QueryLink else if (Action == IIPPacketRequest.QueryLink
|| Action == IIPPacketAction.LinkTemplates) || Action == IIPPacketRequest.LinkTemplates)
{ {
if (NotEnough(offset, ends, 2)) if (NotEnough(offset, ends, 2))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -430,8 +381,8 @@ class IIPPacket : Packet
ResourceLink = data.GetString(offset, cl); ResourceLink = data.GetString(offset, cl);
offset += cl; offset += cl;
} }
else if (Action == IIPPacketAction.ResourceChildren else if (Action == IIPPacketRequest.ResourceChildren
|| Action == IIPPacketAction.ResourceParents) || Action == IIPPacketRequest.ResourceParents)
{ {
if (NotEnough(offset, ends, 4)) if (NotEnough(offset, ends, 4))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -439,7 +390,7 @@ class IIPPacket : Packet
ResourceId = data.GetUInt32(offset, Endian.Little); ResourceId = data.GetUInt32(offset, Endian.Little);
offset += 4; offset += 4;
} }
else if (Action == IIPPacketAction.ResourceHistory) else if (Action == IIPPacketRequest.ResourceHistory)
{ {
if (NotEnough(offset, ends, 20)) if (NotEnough(offset, ends, 20))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -454,7 +405,7 @@ class IIPPacket : Packet
offset += 8; offset += 8;
} }
else if (Action == IIPPacketAction.InvokeFunction) else if (Action == IIPPacketRequest.InvokeFunction)
{ {
if (NotEnough(offset, ends, 6)) if (NotEnough(offset, ends, 6))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -482,8 +433,8 @@ class IIPPacket : Packet
//offset += cl; //offset += cl;
} }
else if (Action == IIPPacketAction.Listen else if (Action == IIPPacketRequest.Listen
|| Action == IIPPacketAction.Unlisten)// .GetProperty) || Action == IIPPacketRequest.Unlisten)// .GetProperty)
{ {
if (NotEnough(offset, ends, 5)) if (NotEnough(offset, ends, 5))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -508,7 +459,7 @@ class IIPPacket : Packet
// offset += 8; // offset += 8;
//} //}
else if (Action == IIPPacketAction.SetProperty) else if (Action == IIPPacketRequest.SetProperty)
{ {
if (NotEnough(offset, ends, 6)) if (NotEnough(offset, ends, 6))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -530,10 +481,10 @@ class IIPPacket : Packet
} }
// Attributes // Attributes
else if (Action == IIPPacketAction.UpdateAllAttributes else if (Action == IIPPacketRequest.UpdateAllAttributes
|| Action == IIPPacketAction.GetAttributes || Action == IIPPacketRequest.GetAttributes
|| Action == IIPPacketAction.UpdateAttributes || Action == IIPPacketRequest.UpdateAttributes
|| Action == IIPPacketAction.ClearAttributes) || Action == IIPPacketRequest.ClearAttributes)
{ {
if (NotEnough(offset, ends, 8)) if (NotEnough(offset, ends, 8))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -551,7 +502,7 @@ class IIPPacket : Packet
offset += cl; offset += cl;
} }
else if (Action == IIPPacketAction.KeepAlive) else if (Action == IIPPacketRequest.KeepAlive)
{ {
if (NotEnough(offset, ends, 12)) if (NotEnough(offset, ends, 12))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -562,7 +513,7 @@ class IIPPacket : Packet
offset += 4; offset += 4;
} }
else if (Action == IIPPacketAction.ProcedureCall) else if (Action == IIPPacketRequest.ProcedureCall)
{ {
if (NotEnough(offset, ends, 2)) if (NotEnough(offset, ends, 2))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -587,7 +538,7 @@ class IIPPacket : Packet
offset += (uint)size; offset += (uint)size;
} }
else if (Action == IIPPacketAction.StaticCall) else if (Action == IIPPacketRequest.StaticCall)
{ {
if (NotEnough(offset, ends, 18)) if (NotEnough(offset, ends, 18))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -608,8 +559,8 @@ class IIPPacket : Packet
} }
else if (Command == IIPPacketCommand.Reply) else if (Command == IIPPacketCommand.Reply)
{ {
if (Action == IIPPacketAction.AttachResource if (Action == IIPPacketRequest.AttachResource
|| Action == IIPPacketAction.ReattachResource) || Action == IIPPacketRequest.ReattachResource)
{ {
if (NotEnough(offset, ends, 26)) if (NotEnough(offset, ends, 26))
@@ -644,11 +595,11 @@ class IIPPacket : Packet
//Content = data.Clip(DataType.Value.Offset, (uint)DataType.Value.ContentLength); //Content = data.Clip(DataType.Value.Offset, (uint)DataType.Value.ContentLength);
} }
else if (Action == IIPPacketAction.DetachResource) else if (Action == IIPPacketRequest.DetachResource)
{ {
// nothing to do // nothing to do
} }
else if (Action == IIPPacketAction.CreateResource) else if (Action == IIPPacketRequest.CreateResource)
{ {
if (NotEnough(offset, ends, 20)) if (NotEnough(offset, ends, 20))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -660,22 +611,22 @@ class IIPPacket : Packet
offset += 4; offset += 4;
} }
else if (Action == IIPPacketAction.DetachResource) else if (Action == IIPPacketRequest.DetachResource)
{ {
// nothing to do // nothing to do
} }
// Inquire // Inquire
else if (Action == IIPPacketAction.TemplateFromClassName else if (Action == IIPPacketRequest.TemplateFromClassName
|| Action == IIPPacketAction.TemplateFromClassId || Action == IIPPacketRequest.TemplateFromClassId
|| Action == IIPPacketAction.TemplateFromResourceId || Action == IIPPacketRequest.TemplateFromResourceId
|| Action == IIPPacketAction.QueryLink || Action == IIPPacketRequest.QueryLink
|| Action == IIPPacketAction.ResourceChildren || Action == IIPPacketRequest.ResourceChildren
|| Action == IIPPacketAction.ResourceParents || Action == IIPPacketRequest.ResourceParents
|| Action == IIPPacketAction.ResourceHistory || Action == IIPPacketRequest.ResourceHistory
|| Action == IIPPacketAction.LinkTemplates || Action == IIPPacketRequest.LinkTemplates
// Attribute // Attribute
|| Action == IIPPacketAction.GetAllAttributes || Action == IIPPacketRequest.GetAllAttributes
|| Action == IIPPacketAction.GetAttributes) || Action == IIPPacketRequest.GetAttributes)
{ {
if (NotEnough(offset, ends, 1)) if (NotEnough(offset, ends, 1))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -696,9 +647,9 @@ class IIPPacket : Packet
//Content = data.Clip(offset, cl); //Content = data.Clip(offset, cl);
//offset += cl; //offset += cl;
} }
else if (Action == IIPPacketAction.InvokeFunction else if (Action == IIPPacketRequest.InvokeFunction
|| Action == IIPPacketAction.ProcedureCall || Action == IIPPacketRequest.ProcedureCall
|| Action == IIPPacketAction.StaticCall) || Action == IIPPacketRequest.StaticCall)
{ {
if (NotEnough(offset, ends, 1)) if (NotEnough(offset, ends, 1))
return -dataLengthNeeded; return -dataLengthNeeded;
@@ -712,13 +663,13 @@ class IIPPacket : Packet
//Content = data.Clip(DataType.Value.Offset, (uint)DataType.Value.ContentLength); //Content = data.Clip(DataType.Value.Offset, (uint)DataType.Value.ContentLength);
} }
else if (Action == IIPPacketAction.SetProperty else if (Action == IIPPacketRequest.SetProperty
|| Action == IIPPacketAction.Listen || Action == IIPPacketRequest.Listen
|| Action == IIPPacketAction.Unlisten) || Action == IIPPacketRequest.Unlisten)
{ {
// nothing to do // nothing to do
} }
else if (Action == IIPPacketAction.KeepAlive) else if (Action == IIPPacketRequest.KeepAlive)
{ {
if (NotEnough(offset, ends, 12)) if (NotEnough(offset, ends, 12))
return -dataLengthNeeded; return -dataLengthNeeded;

View File

@@ -1,50 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Esiur.Net.Packets
{
public enum IIPPacketAction : byte
{
// Request Manage
AttachResource = 0,
ReattachResource,
DetachResource,
CreateResource,
DeleteResource,
AddChild,
RemoveChild,
RenameResource,
// Request Inquire
TemplateFromClassName = 0x8,
TemplateFromClassId,
TemplateFromResourceId,
QueryLink,
ResourceHistory,
ResourceChildren,
ResourceParents,
LinkTemplates,
// Request Invoke
InvokeFunction = 0x10,
Reserved,
Listen,
Unlisten,
SetProperty,
// Request Attribute
GetAllAttributes = 0x18,
UpdateAllAttributes,
ClearAllAttributes,
GetAttributes,
UpdateAttributes,
ClearAttributes,
// Static calling
KeepAlive = 0x20,
ProcedureCall,
StaticCall
}
}

View File

@@ -4,11 +4,11 @@ using System.Text;
namespace Esiur.Net.Packets namespace Esiur.Net.Packets
{ {
public enum IIPPacketCommand : byte public enum IIPPacketMethod : byte
{ {
Event = 0, Notification = 0,
Request, Request,
Reply, Reply,
Report, Extension,
} }
} }

View File

@@ -1,22 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Esiur.Net.Packets
{
public enum IIPPacketEvent : byte
{
// Event Manage
ResourceReassigned = 0,
ResourceDestroyed,
ChildAdded,
ChildRemoved,
Renamed,
// Event Invoke
PropertyUpdated = 0x10,
EventOccurred,
// Attribute
AttributesUpdated = 0x18
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Esiur.Net.Packets
{
public enum IIPPacketNotification : byte
{
// Event Manage
ResourceDestroyed = 0,
ResourceReassigned,
ResourceMoved,
SystemFailure,
// Event Invoke
PropertyModified = 0x8,
EventOccurred,
}
}

View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Esiur.Net.Packets
{
public enum IIPPacketReply : byte
{
// Success
Completed = 0x0,
Propagated = 0x1,
// Error
Permission = 0x81,
Execution = 0x82,
// Partial
Progress = 0x10,
Chunk = 0x11,
Warning = 0x12
}
}

View File

@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Esiur.Net.Packets
{
public enum IIPPacketRequest : byte
{
// Request Manage
AttachResource = 0x0,
ReattachResource = 0x1,
DetachResource = 0x2,
CreateResource = 0x3,
DeleteResource = 0x4,
MoveResource = 0x5,
// Request Inquire
TemplateFromClassName = 0x8,
TemplateFromClassId = 0x9,
TemplateFromResourceId = 0xA,
QueryLink = 0xB,
LinkTemplates = 0xC,
Token = 0xD,
// Request Invoke
InvokeFunction = 0x10,
Subscribe = 0x11,
Unsubscribe = 0x12,
SetProperty = 0x13,
// Static calling
KeepAlive = 0x18,
ProcedureCall = 0x19,
StaticCall = 0x1A
}
}