2
0
mirror of https://github.com/esiur/esiur-js.git synced 2026-04-03 21:48:21 +00:00

Static Calling

This commit is contained in:
2022-08-07 23:08:33 +03:00
parent 551f0f4684
commit bf861395c3
10 changed files with 429 additions and 77 deletions

View File

@@ -55,6 +55,10 @@ export default class IIPPacket
this.originalOffset = 0;
this.resourceName = "";
this.dataType = null;
this.jitter = 0;
this.interval = 0;
this.procedure = "";
this.currentTime = null;
}
notEnough(offset, ends, needed)
@@ -62,7 +66,6 @@ export default class IIPPacket
if (offset + needed > ends)
{
this.dataLengthNeeded = needed - (ends - offset);
// this.dataLengthNeeded = needed - (ends - this.originalOffset);
return true;
}
else
@@ -425,7 +428,56 @@ export default class IIPPacket
//this.content = data.clip(offset, cl);
offset += cl;
}
else if (this.action == IIPPacketAction.KeepAlive)
{
if (this.notEnough(offset, ends, 12))
return -this.dataLengthNeeded;
this.currentTime = data.getDateTime(offset);
offset += 8;
this.interval = data.getUint32(offset);
offset += 4;
}
else if (this.action == IIPPacketAction.ProcedureCall)
{
if (this.notEnough(offset, ends, 2))
return -this.dataLengthNeeded;
let cl = data.getUint16(offset);
offset += 2;
if (this.notEnough(offset, ends, cl))
return -this.dataLengthNeeded;
this.procedure = data.getString(offset, cl);
offset += cl;
if (this.notEnough(offset, ends, 1))
return -this.dataLengthNeeded;
let parsed = TransmissionType.parse(data, offset, ends);
if (parsed.type == null) return -parsed.size;
offset += parsed.size;
} else if (this.action == IIPPacketAction.StaticCall)
{
if (this.notEnough(offset, ends, 18))
return -this.dataLengthNeeded;
this.classId = data.getGuid(offset);
offset += 16;
this.methodIndex = data[offset++];
let parsed = TransmissionType.Pparse(data, offset, ends);
if (parsed.type == null) return -parsed.size;
offset += parsed.size;
}
}
else if (this.command == IIPPacketCommand.Reply)
{
@@ -499,7 +551,9 @@ export default class IIPPacket
offset += parsed.size;
}
else if (this.action == IIPPacketAction.InvokeFunction)
else if (this.action == IIPPacketAction.InvokeFunction
|| this.action == IIPPacketAction.ProcedureCall
|| this.action == IIPPacketAction.StaticCall )
{
if (this.notEnough(offset, ends, 1))
@@ -519,6 +573,16 @@ export default class IIPPacket
{
// nothing to do
}
else if (this.action == IIPPacketAction.KeepAlive)
{
if (this.notEnough(offset, ends, 12))
return -this.dataLengthNeeded;
this.currentTime = data.getDateTime(offset);
offset += 8;
this.jitter = data.GetUint32(offset);
offset += 4;
}
}
else if (this.command == IIPPacketCommand.Report)
{

View File

@@ -33,5 +33,11 @@ export default // const IIPPacketAction =
ClearAllAttributes: 26,
GetAttributes: 27,
UpdateAttributes: 28,
ClearAttributes: 29
ClearAttributes: 29,
// Static
KeepAlive: 0x20,
ProcedureCall: 0x21,
StaticCall: 0x22
};