2
0
mirror of https://github.com/esiur/esiur-js.git synced 2026-03-18 15:30:38 +00:00

Instance.Link

This commit is contained in:
2022-08-13 04:00:26 +03:00
parent 1985363ad7
commit 2689bb7fd5
12 changed files with 1595 additions and 829 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -213,7 +213,7 @@ export default class DistributedResource extends IResource
if (!et.listenable)
return new AsyncReply().triggerError(new AsyncException(ErrorType.Management, ExceptionCode.NotListenable, ""));
return this._p.connection.sendListenRequest(this._p.instanceId, et.index);
return this._p.connection._sendListenRequest(this._p.instanceId, et.index);
}
unlisten(event)
@@ -226,7 +226,7 @@ export default class DistributedResource extends IResource
if (!et.listenable)
return new AsyncReply().triggerError(new AsyncException(ErrorType.Management, ExceptionCode.NotListenable, ""));
return this._p.connection.sendUnlistenRequest(this._p.instanceId, et.index);
return this._p.connection._sendUnlistenRequest(this._p.instanceId, et.index);
}
_emitEventByIndex(index, args)
@@ -257,9 +257,8 @@ export default class DistributedResource extends IResource
if (ft.isStatic)
return this._p.connection.staticCall(this.instance.template.classId, index, args);
else
return this._p.connection.sendInvoke(this._p.instanceId, index, args);
return this._p.connection._sendInvoke(this._p.instanceId, index, args);
//return this._p.connection.sendInvoke(this._p.instanceId, index, args);
}
_get(index)
@@ -301,7 +300,7 @@ export default class DistributedResource extends IResource
var parameters = Codec.compose(value, this._p.connection);
var self = this;
this._p.connection.sendRequest(IIPPacketAction.SetProperty)
this._p.connection._sendRequest(IIPPacketAction.SetProperty)
.addUint32(self._p.instanceId).addUint8(index).addUint8Array(parameters)
.done()
.then(function(res)

View File

@@ -31,6 +31,7 @@ import IIPPacketCommand from "./IIPPacketCommand.js";
import IIPPacketEvent from "./IIPPacketEvent.js";
import IIPPacketReport from "./IIPPacketReport.js";
import TransmissionType from '../../Data/TransmissionType.js';
import ExceptionCode from "../../Core/ExceptionCode.js";
export default class IIPPacket
{
@@ -81,6 +82,7 @@ export default class IIPPacket
this.command = (data.getUint8(offset) >> 6);
if (this.command == IIPPacketCommand.Event)
{
this.event = (data.getUint8(offset++) & 0x3f);
@@ -104,7 +106,7 @@ export default class IIPPacket
else
{
this.action = (data.getUint8(offset++) & 0x3f);
if (this.notEnough(offset, ends, 4))
return -this.dataLengthNeeded;
@@ -183,6 +185,9 @@ export default class IIPPacket
offset += cl;
}
else {
throw new Error("Unknown event packet.");
}
}
else if (this.command == IIPPacketCommand.Request)
{
@@ -478,6 +483,9 @@ export default class IIPPacket
offset += parsed.size;
}
else {
throw new Error("Unknown request packet.");
}
}
else if (this.command == IIPPacketCommand.Reply)
{
@@ -580,9 +588,12 @@ export default class IIPPacket
this.currentTime = data.getDateTime(offset);
offset += 8;
this.jitter = data.GetUint32(offset);
this.jitter = data.getUint32(offset);
offset += 4;
}
else {
throw new Error("Unknown reply packet.");
}
}
else if (this.command == IIPPacketCommand.Report)
{
@@ -637,6 +648,9 @@ export default class IIPPacket
offset += parsed.size;
}
else {
throw new Error("Unknown report packet.");
}
}
return offset - this.originalOffset;

View File

@@ -4,7 +4,8 @@ import ExceptionCode from "../../Core/ExceptionCode.js";
import ISocket from "./ISocket.js";
import SocketState from "./SocketState.js";
import NetworkBuffer from "../NetworkBuffer.js";
import DC from '../../Data/DC.js';
export default class WSocket extends ISocket
{
constructor(websocket){
@@ -51,6 +52,7 @@ export default class WSocket extends ISocket
{
try
{
//console.log("TX", new DC(message));
this.ws.send(message);
} catch {
this.state = SocketState.Closed;
@@ -172,6 +174,7 @@ export default class WSocket extends ISocket
try {
this.ws.send(message);
//console.log("TX", message);
} catch {
this.state = SocketState.Closed;
}