mirror of
https://github.com/esiur/esiur-js.git
synced 2025-05-06 04:22:58 +00:00
Deadlock prevention
This commit is contained in:
parent
fa76cf99a6
commit
0db7f6c1e4
@ -46,7 +46,7 @@
|
||||
users.append(el);
|
||||
|
||||
if (!silent)
|
||||
appendMessage({usr, msg: "joined the room", date: new Date()});
|
||||
appendMessage(new Map([['usr', usr], ['msg', "joined the room"], ['date', new Date()]]));
|
||||
}
|
||||
|
||||
function removeUser(usr){
|
||||
@ -57,7 +57,7 @@
|
||||
break;
|
||||
}
|
||||
|
||||
appendMessage({usr, msg: "left the room", date: new Date()});
|
||||
appendMessage(new Map([['usr', usr], ['msg', "left the room"], ['date', new Date()]]));
|
||||
}
|
||||
|
||||
function updateTitle()
|
||||
|
@ -147,7 +147,7 @@ export default class Codec {
|
||||
/// <returns>Value</returns>
|
||||
static parse(
|
||||
data, offset, connection,
|
||||
dataType = null) {
|
||||
requestSequence, dataType = null) {
|
||||
|
||||
let len = 0;
|
||||
|
||||
@ -164,18 +164,18 @@ export default class Codec {
|
||||
return new CodecParseResults(
|
||||
len,
|
||||
Codec.fixedParsers[dataType.exponent][dataType.index](
|
||||
data, dataType.offset, dataType.contentLength, connection));
|
||||
data, dataType.offset, dataType.contentLength, connection, requestSequence));
|
||||
} else if (dataType.classType == TransmissionTypeClass.Dynamic) {
|
||||
return new CodecParseResults(
|
||||
len,
|
||||
Codec.dynamicParsers[dataType.index](
|
||||
data, dataType.offset, dataType.contentLength, connection));
|
||||
data, dataType.offset, dataType.contentLength, connection, requestSequence));
|
||||
} else //if (tt.Class == TransmissionTypeClass.Typed)
|
||||
{
|
||||
return new CodecParseResults(
|
||||
len,
|
||||
Codec.typedParsers[dataType.index](
|
||||
data, dataType.offset, dataType.contentLength, connection));
|
||||
data, dataType.offset, dataType.contentLength, connection, requestSequence));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,9 @@ import PropertyValueArray from './PropertyValueArray.js';
|
||||
import PropertyValue from './PropertyValue.js';
|
||||
import Record from './Record.js';
|
||||
import { UInt64, Int64 } from '../Data/ExtendedTypes.js';
|
||||
import AsyncException from '../Core/AsyncException.js';
|
||||
import ExceptionCode from '../Core/ExceptionCode.js';
|
||||
import ErrorType from '../Core/ErrorType.js';
|
||||
|
||||
export class PropertyValueParserResults {
|
||||
//final int size;
|
||||
@ -26,135 +29,135 @@ export class PropertyValueParserResults {
|
||||
}
|
||||
|
||||
export default class DataDeserializer {
|
||||
static nullParser(data, offset, length, connection) {
|
||||
static nullParser(data, offset, length, connection, requestSequence) {
|
||||
return new AsyncReply(null);
|
||||
}
|
||||
|
||||
static booleanTrueParser(
|
||||
data, offset, length, connection) {
|
||||
data, offset, length, connection, requestSequence) {
|
||||
return new AsyncReply(true);
|
||||
}
|
||||
|
||||
static booleanFalseParser(
|
||||
data, offset, length, connection) {
|
||||
data, offset, length, connection, requestSequence) {
|
||||
return new AsyncReply(false);
|
||||
}
|
||||
|
||||
static notModifiedParser(
|
||||
data, offset, length, connection) {
|
||||
data, offset, length, connection, requestSequence) {
|
||||
return new AsyncReply(NotModified());
|
||||
}
|
||||
|
||||
static byteParser(
|
||||
data, offset, length, connection) {
|
||||
data, offset, length, connection, requestSequence) {
|
||||
return new AsyncReply(data[offset]);
|
||||
}
|
||||
|
||||
static sByteParser(
|
||||
data, offset, length, connection) {
|
||||
data, offset, length, connection, requestSequence) {
|
||||
return new AsyncReply(
|
||||
data[offset] > 127 ? data[offset] - 256 : data[offset]);
|
||||
}
|
||||
|
||||
static char16Parser(
|
||||
data, offset, length, connection) {
|
||||
data, offset, length, connection, requestSequence) {
|
||||
return new AsyncReply(data.getChar(offset));
|
||||
}
|
||||
|
||||
static char8Parser(
|
||||
data, offset, length, connection) {
|
||||
data, offset, length, connection, requestSequence) {
|
||||
return new AsyncReply(String.fromCharCode(data[offset]));
|
||||
}
|
||||
|
||||
static int16Parser(
|
||||
data, offset, length, connection) {
|
||||
data, offset, length, connection, requestSequence) {
|
||||
return new AsyncReply(data.getInt16(offset));
|
||||
}
|
||||
|
||||
static uInt16Parser(
|
||||
data, offset, length, connection) {
|
||||
data, offset, length, connection, requestSequence) {
|
||||
return new AsyncReply(data.getUint16(offset));
|
||||
}
|
||||
|
||||
static int32Parser(
|
||||
data, offset, length, connection) {
|
||||
data, offset, length, connection, requestSequence) {
|
||||
return new AsyncReply(data.getInt32(offset));
|
||||
}
|
||||
|
||||
static uInt32Parser(
|
||||
data, offset, length, connection) {
|
||||
data, offset, length, connection, requestSequence) {
|
||||
return new AsyncReply(data.getUint32(offset));
|
||||
}
|
||||
|
||||
static float32Parser(
|
||||
data, offset, length, connection) {
|
||||
data, offset, length, connection, requestSequence) {
|
||||
return new AsyncReply(data.getFloat32(offset));
|
||||
}
|
||||
|
||||
static float64Parser(
|
||||
data, offset, length, connection) {
|
||||
data, offset, length, connection, requestSequence) {
|
||||
return new AsyncReply(data.getFloat64(offset));
|
||||
}
|
||||
|
||||
static float128Parser(
|
||||
data, offset, length, connection) {
|
||||
data, offset, length, connection, requestSequence) {
|
||||
// @TODO
|
||||
return new AsyncReply(data.getFloat64(offset));
|
||||
}
|
||||
|
||||
static int128Parser(
|
||||
data, offset, length, connection) {
|
||||
data, offset, length, connection, requestSequence) {
|
||||
// @TODO
|
||||
return new AsyncReply(data.getInt64(offset));
|
||||
}
|
||||
|
||||
static uInt128Parser(
|
||||
data, offset, length, connection) {
|
||||
data, offset, length, connection, requestSequence) {
|
||||
return new AsyncReply(data.getUint64(offset));
|
||||
}
|
||||
|
||||
static int64Parser(
|
||||
data, offset, length, connection) {
|
||||
data, offset, length, connection, requestSequence) {
|
||||
return new AsyncReply(new Int64(data.getInt64(offset)));
|
||||
}
|
||||
|
||||
static uInt64Parser(
|
||||
data, offset, length, connection) {
|
||||
data, offset, length, connection, requestSequence) {
|
||||
return new AsyncReply(new UInt64(data.getUint64(offset)));
|
||||
}
|
||||
|
||||
static dateTimeParser(
|
||||
data, offset, length, connection) {
|
||||
data, offset, length, connection, requestSequence) {
|
||||
return new AsyncReply(data.getDateTime(offset));
|
||||
}
|
||||
|
||||
static resourceParser(
|
||||
data, offset, length, connection) {
|
||||
data, offset, length, connection, requestSequence) {
|
||||
if (connection != null) {
|
||||
var id = data.getUint32(offset);
|
||||
var id = data.getUint32(offset, requestSequence);
|
||||
return connection.fetch(id);
|
||||
}
|
||||
throw Error("Can't parse resource with no connection");
|
||||
}
|
||||
|
||||
static localResourceParser(
|
||||
data, offset, length, connection) {
|
||||
data, offset, length, connection, requestSequence) {
|
||||
var id = data.getUint32(offset);
|
||||
return Warehouse.getById(id);
|
||||
}
|
||||
|
||||
static rawDataParser(
|
||||
data, offset, length, connection) {
|
||||
data, offset, length, connection, requestSequence) {
|
||||
return new AsyncReply(data.clip(offset, length));
|
||||
}
|
||||
|
||||
static stringParser(
|
||||
data, offset, length, connection) {
|
||||
data, offset, length, connection, requestSequence) {
|
||||
return new AsyncReply(data.getString(offset, length));
|
||||
}
|
||||
|
||||
static recordParser(
|
||||
data, offset, length, connection) {
|
||||
data, offset, length, connection, requestSequence) {
|
||||
var reply = new AsyncReply();
|
||||
|
||||
var classId = data.getGuid(offset);
|
||||
@ -163,8 +166,8 @@ export default class DataDeserializer {
|
||||
|
||||
var template = Warehouse.getTemplateByClassId(classId, TemplateType.Record);
|
||||
|
||||
if (template != null) {
|
||||
DataDeserializer.listParser(data, offset, length, connection).then((ar) => {
|
||||
var initRecord = (template) => {
|
||||
DataDeserializer.listParser(data, offset, length, connection, requestSequence).then((ar) => {
|
||||
let record;
|
||||
|
||||
if (template.definedType != null) {
|
||||
@ -178,27 +181,25 @@ export default class DataDeserializer {
|
||||
|
||||
reply.trigger(record);
|
||||
});
|
||||
};
|
||||
|
||||
if (template != null) {
|
||||
initRecord(template);
|
||||
} else {
|
||||
if (connection == null)
|
||||
throw Error("Can't parse record with no connection");
|
||||
|
||||
connection.getTemplate(classId).then((tmp) => {
|
||||
if (tmp == null)
|
||||
reply.triggerError(new Error("Couldn't fetch record template."));
|
||||
|
||||
DataDeserializer.listParser(data, offset, length, connection).then((ar) => {
|
||||
|
||||
var record = new Record();
|
||||
|
||||
//var kv = new Map();
|
||||
|
||||
for (var i = 0; i < tmp.properties.length; i++)
|
||||
record[tmp.properties[i].name] = ar[i];
|
||||
|
||||
//record.deserialize(kv);
|
||||
|
||||
reply.trigger(record);
|
||||
});
|
||||
{
|
||||
reply.triggerError(new AsyncException(
|
||||
ErrorType.Management,
|
||||
ExceptionCode.TemplateNotFound.index,
|
||||
"Template not found for record."));
|
||||
} else {
|
||||
initRecord(tmp);
|
||||
}
|
||||
|
||||
}).error((x) => reply.triggerError(x));
|
||||
}
|
||||
|
||||
@ -206,11 +207,11 @@ export default class DataDeserializer {
|
||||
}
|
||||
|
||||
static constantParser(
|
||||
data, offset, length, connection) {
|
||||
data, offset, length, connection, requestSequence) {
|
||||
throw Error("NotImplementedException");
|
||||
}
|
||||
|
||||
static enumParser(data, offset, length, connection) {
|
||||
static enumParser(data, offset, length, connection, requestSequence) {
|
||||
var classId = data.getGuid(offset);
|
||||
offset += 16;
|
||||
var index = data[offset++];
|
||||
@ -254,11 +255,11 @@ export default class DataDeserializer {
|
||||
}
|
||||
|
||||
static recordListParser(
|
||||
data, offset, length, connection) {
|
||||
data, offset, length, connection, requestSequence) {
|
||||
var rt = new AsyncBag();
|
||||
|
||||
while (length > 0) {
|
||||
var parsed = Codec.parse(data, offset, connection);
|
||||
var parsed = Codec.parse(data, offset, connection, requestSequence);
|
||||
|
||||
rt.add(parsed.reply);
|
||||
|
||||
@ -274,11 +275,11 @@ export default class DataDeserializer {
|
||||
}
|
||||
|
||||
static resourceListParser(
|
||||
data, offset, length, connection) {
|
||||
data, offset, length, connection, requestSequence) {
|
||||
var rt = new AsyncBag();
|
||||
|
||||
while (length > 0) {
|
||||
var parsed = Codec.parse(data, offset, connection);
|
||||
var parsed = Codec.parse(data, offset, connection, requestSequence);
|
||||
|
||||
rt.add(parsed.reply);
|
||||
|
||||
@ -294,11 +295,11 @@ export default class DataDeserializer {
|
||||
}
|
||||
|
||||
static listParser(
|
||||
data, offset, length, connection) {
|
||||
data, offset, length, connection, requestSequence) {
|
||||
var rt = new AsyncBag();
|
||||
|
||||
while (length > 0) {
|
||||
var parsed = Codec.parse(data, offset, connection);
|
||||
var parsed = Codec.parse(data, offset, connection, requestSequence);
|
||||
|
||||
rt.add(parsed.reply);
|
||||
|
||||
@ -314,7 +315,7 @@ export default class DataDeserializer {
|
||||
}
|
||||
|
||||
static typedMapParser(
|
||||
data, offset, length, connection) {
|
||||
data, offset, length, connection, requestSequence) {
|
||||
// get key type
|
||||
var keyRep = RepresentationType.parse(data, offset);
|
||||
offset += keyRep.size;
|
||||
@ -332,7 +333,7 @@ export default class DataDeserializer {
|
||||
var results = new AsyncBag();
|
||||
|
||||
while (length > 0) {
|
||||
var parsed = Codec.parse(data, offset, connection);
|
||||
var parsed = Codec.parse(data, offset, connection, requestSequence);
|
||||
|
||||
results.add(parsed.reply);
|
||||
|
||||
@ -356,7 +357,7 @@ export default class DataDeserializer {
|
||||
}
|
||||
|
||||
static tupleParser(
|
||||
data, offset, length, connection) {
|
||||
data, offset, length, connection, requestSequence) {
|
||||
|
||||
|
||||
var results = new AsyncBag();
|
||||
@ -368,7 +369,7 @@ export default class DataDeserializer {
|
||||
var types = [];
|
||||
|
||||
for (var i = 0; i < tupleSize; i++) {
|
||||
var rep = RepresentationType.parse(data, offset);
|
||||
var rep = RepresentationType.parse(data, offset, requestSequence);
|
||||
if (rep.type != null)
|
||||
types.push(rep.type.getRuntimeType() ?? Object);
|
||||
offset += rep.size;
|
||||
@ -376,7 +377,7 @@ export default class DataDeserializer {
|
||||
}
|
||||
|
||||
while (length > 0) {
|
||||
var parsed = Codec.parse(data, offset, connection);
|
||||
var parsed = Codec.parse(data, offset, connection, requestSequence);
|
||||
|
||||
results.add(parsed.reply);
|
||||
|
||||
@ -397,7 +398,7 @@ export default class DataDeserializer {
|
||||
}
|
||||
|
||||
static typedListParser(
|
||||
data, offset, length, connection) {
|
||||
data, offset, length, connection, requestSequence) {
|
||||
var rt = new AsyncBag();
|
||||
|
||||
// get the type
|
||||
@ -411,7 +412,7 @@ export default class DataDeserializer {
|
||||
rt.arrayType = runtimeType;
|
||||
|
||||
while (length > 0) {
|
||||
var parsed = Codec.parse(data, offset, connection);
|
||||
var parsed = Codec.parse(data, offset, connection, requestSequence);
|
||||
|
||||
rt.add(parsed.reply);
|
||||
|
||||
@ -430,11 +431,11 @@ export default class DataDeserializer {
|
||||
data,
|
||||
offset,
|
||||
length,
|
||||
connection) //, bool ageIncluded = true)
|
||||
connection, requestSequence) //, bool ageIncluded = true)
|
||||
{
|
||||
var rt = new AsyncBag();
|
||||
|
||||
DataDeserializer.listParser(data, offset, length, connection).then((x) => {
|
||||
DataDeserializer.listParser(data, offset, length, connection, requestSequence).then((x) => {
|
||||
var pvs = new PropertyValueArray();
|
||||
|
||||
for (var i = 0; i < x.length; i += 3)
|
||||
@ -447,7 +448,7 @@ export default class DataDeserializer {
|
||||
}
|
||||
|
||||
static propertyValueParser(data, offset,
|
||||
connection) //, bool ageIncluded = true)
|
||||
connection, requestSequence) //, bool ageIncluded = true)
|
||||
{
|
||||
let reply = new AsyncReply();
|
||||
|
||||
@ -457,7 +458,7 @@ export default class DataDeserializer {
|
||||
let date = data.getDateTime(offset);
|
||||
offset += 8;
|
||||
|
||||
let parsed = Codec.parse(data, offset, connection);
|
||||
let parsed = Codec.parse(data, offset, connection, requestSequence);
|
||||
|
||||
parsed.reply.then((value) => {
|
||||
reply.trigger(new PropertyValue(value, age, date));
|
||||
@ -468,7 +469,7 @@ export default class DataDeserializer {
|
||||
|
||||
static
|
||||
historyParser(data, offset, length, resource,
|
||||
connection) {
|
||||
connection, requestSequence) {
|
||||
throw new Error("Not implemented");
|
||||
// @TODO
|
||||
// var list = new KeyList<PropertyTemplate, List<PropertyValue>>();
|
||||
|
@ -949,7 +949,7 @@ export default class DistributedConnection extends IStore {
|
||||
|
||||
for (var i = 0; i < this.resources.keys.length; i++) {
|
||||
var index = this.resources.keys[i];
|
||||
bag.add(this.fetch(index));
|
||||
bag.add(this.fetch(index, null));
|
||||
}
|
||||
|
||||
bag.seal();
|
||||
@ -1367,7 +1367,7 @@ export default class DistributedConnection extends IStore {
|
||||
|
||||
this.requests.remove(callbackId);
|
||||
|
||||
Codec.parse(data, 0, this, dataType).reply.then(function (rt) {
|
||||
Codec.parse(data, 0, this, null, dataType).reply.then(function (rt) {
|
||||
req.trigger(rt);
|
||||
});
|
||||
}
|
||||
@ -1391,7 +1391,7 @@ export default class DistributedConnection extends IStore {
|
||||
IIPReportChunk(callbackId, dataType, data) {
|
||||
var req = this.requests.item(callbackId);
|
||||
if (req != null) {
|
||||
Codec.parse(data, 0, this, dataType).reply.then(function (x) {
|
||||
Codec.parse(data, 0, this, null, dataType).reply.then(function (x) {
|
||||
req.triggerChunk(x);
|
||||
});
|
||||
}
|
||||
@ -1413,7 +1413,7 @@ export default class DistributedConnection extends IStore {
|
||||
|
||||
let self = this;
|
||||
|
||||
this.fetch(resourceId).then(function (r) {
|
||||
this.fetch(resourceId, null).then(function (r) {
|
||||
|
||||
let pt = r.instance.template.getPropertyTemplateByIndex(index);
|
||||
|
||||
@ -1424,7 +1424,7 @@ export default class DistributedConnection extends IStore {
|
||||
let item = new AsyncReply();
|
||||
self.queue.add(item);
|
||||
|
||||
Codec.parse(data, 0, self, dataType).reply.then(function (args) {
|
||||
Codec.parse(data, 0, self, null, dataType).reply.then(function (args) {
|
||||
item.trigger(new DistributedResourceQueueItem(r, DistributedResourceQueueItemType.Propery, args, index));
|
||||
}).error(function (ex) {
|
||||
self.queue.remove(item);
|
||||
@ -1437,7 +1437,7 @@ export default class DistributedConnection extends IStore {
|
||||
IIPEventEventOccurred(resourceId, index, dataType, data) {
|
||||
var self = this;
|
||||
|
||||
this.fetch(resourceId).then(function (r) {
|
||||
this.fetch(resourceId, null).then(function (r) {
|
||||
let et = r.instance.template.getEventTemplateByIndex(index);
|
||||
|
||||
if (et == null)
|
||||
@ -1448,7 +1448,7 @@ export default class DistributedConnection extends IStore {
|
||||
self.queue.add(item);
|
||||
|
||||
// Codec.parseVarArray(content, 0, content.length, self).then(function (args) {
|
||||
Codec.parse(data, 0, self, dataType).reply.then(function (args) {
|
||||
Codec.parse(data, 0, self, null, dataType).reply.then(function (args) {
|
||||
item.trigger(new DistributedResourceQueueItem(r, DistributedResourceQueueItemType.Event, args, index));
|
||||
|
||||
}).error(function (ex) {
|
||||
@ -1461,8 +1461,8 @@ export default class DistributedConnection extends IStore {
|
||||
IIPEventChildAdded(resourceId, childId) {
|
||||
var self = this;
|
||||
|
||||
this.fetch(resourceId).then(function (parent) {
|
||||
self.fetch(childId).then(function (child) {
|
||||
this.fetch(resourceId, null).then(function (parent) {
|
||||
self.fetch(childId, null).then(function (child) {
|
||||
parent.instance.children.add(child);
|
||||
});
|
||||
});
|
||||
@ -1471,15 +1471,15 @@ export default class DistributedConnection extends IStore {
|
||||
IIPEventChildRemoved(resourceId, childId) {
|
||||
var self = this;
|
||||
|
||||
this.fetch(resourceId).then(function (parent) {
|
||||
self.fetch(childId).then(function (child) {
|
||||
this.fetch(resourceId, null).then(function (parent) {
|
||||
self.fetch(childId, null).then(function (child) {
|
||||
parent.instance.children.remove(child);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
IIPEventRenamed(resourceId, name) {
|
||||
this.fetch(resourceId).then(function (resource) {
|
||||
this.fetch(resourceId, null).then(function (resource) {
|
||||
resource.instance.attributes.set("name", name);
|
||||
});
|
||||
}
|
||||
@ -1488,7 +1488,7 @@ export default class DistributedConnection extends IStore {
|
||||
IIPEventAttributesUpdated(resourceId, attributes) {
|
||||
var self = this;
|
||||
|
||||
this.fetch(resourceId).then(function (resource) {
|
||||
this.fetch(resourceId, null).then(function (resource) {
|
||||
var attrs = attributes.getStringArray(0, attributes.length);
|
||||
|
||||
self.getAttributes(resource, attrs).then(function (s) {
|
||||
@ -1691,14 +1691,14 @@ export default class DistributedConnection extends IStore {
|
||||
return;
|
||||
}
|
||||
|
||||
DataDeserializer.listParser(content, offset, cl, self).then(function (parameters) {
|
||||
DataDeserializer.listParser(content, offset, cl, self, null).then(function (parameters) {
|
||||
offset += cl;
|
||||
cl = content.getUint32(offset);
|
||||
DataDeserializer.typedMapParser(content, offset, cl, self).then(function (attributes) {
|
||||
DataDeserializer.typedMapParser(content, offset, cl, self, null).then(function (attributes) {
|
||||
offset += cl;
|
||||
cl = content.length - offset;
|
||||
|
||||
DataDeserializer.typedMapParser(content, offset, cl, self).then(function (values) {
|
||||
DataDeserializer.typedMapParser(content, offset, cl, self, null).then(function (values) {
|
||||
|
||||
|
||||
var resource = new (Function.prototype.bind.apply(type, values));
|
||||
@ -1849,7 +1849,7 @@ export default class DistributedConnection extends IStore {
|
||||
return;
|
||||
}
|
||||
|
||||
Codec.parse(data, 0, self, dataType).reply.then(function (args) {
|
||||
Codec.parse(data, 0, self, null, dataType).reply.then(function (args) {
|
||||
if (r instanceof DistributedResource) {
|
||||
var rt = r._invoke(index, args);
|
||||
if (rt != null) {
|
||||
@ -2121,7 +2121,7 @@ export default class DistributedConnection extends IStore {
|
||||
|
||||
var pt = r.instance.template.getPropertyTemplateByIndex(index);
|
||||
if (pt != null) {
|
||||
Codec.parse(data, 0, self, dataType).reply.then(function (value) {
|
||||
Codec.parse(data, 0, self, null, dataType).reply.then(function (value) {
|
||||
if (r instanceof DistributedResource) {
|
||||
// propagation
|
||||
r._set(index, value).then(function (x) {
|
||||
@ -2225,7 +2225,7 @@ export default class DistributedConnection extends IStore {
|
||||
this.sendRequest(IIPPacketAction.CreateResource).addUint8Array(pkt.ToArray()).done().then(function (args) {
|
||||
var rid = args[0];
|
||||
|
||||
self.fetch(rid).then(function (r) {
|
||||
self.fetch(rid, null).then(function (r) {
|
||||
reply.trigger(r);
|
||||
});
|
||||
});
|
||||
@ -2248,7 +2248,7 @@ export default class DistributedConnection extends IStore {
|
||||
let dataType = ar[0];
|
||||
let data = ar[1];
|
||||
|
||||
Codec.parse(data, 0, self, dataType).reply.then((resources) => {
|
||||
Codec.parse(data, 0, self, null, dataType).reply.then((resources) => {
|
||||
reply.trigger((resources))
|
||||
}
|
||||
).error((ex) => reply.triggerError(ex));
|
||||
@ -2377,15 +2377,13 @@ export default class DistributedConnection extends IStore {
|
||||
}
|
||||
|
||||
// Get a resource from the other end
|
||||
fetch(id) {
|
||||
fetch(id, requestSequence) {
|
||||
|
||||
let resource = this.resources.item(id);
|
||||
let request = this.resourceRequests.item(id);
|
||||
|
||||
if (request != null) {
|
||||
|
||||
if (resource != null)
|
||||
// dig for dead locks // or not
|
||||
if (resource != null && (requestSequence?.contains(id) ?? false))
|
||||
return new AsyncReply(resource);
|
||||
else
|
||||
return request;
|
||||
@ -2398,6 +2396,9 @@ export default class DistributedConnection extends IStore {
|
||||
|
||||
this.resourceRequests.set(id, reply);
|
||||
|
||||
var newSequence =
|
||||
requestSequence != null ? [...requestSequence, id] : [id];
|
||||
|
||||
var self = this;
|
||||
|
||||
this.sendRequest(IIPPacketAction.AttachResource)
|
||||
@ -2405,11 +2406,19 @@ export default class DistributedConnection extends IStore {
|
||||
.done()
|
||||
.then(function (rt) {
|
||||
|
||||
if (rt == null) {
|
||||
reply.triggerError(new AsyncException(ErrorType.Management,
|
||||
ExceptionCode.ResourceNotFound, "Null response"));
|
||||
return;
|
||||
}
|
||||
|
||||
var dr;
|
||||
let classId = rt[0];
|
||||
let template = null;
|
||||
|
||||
if (resource == null)
|
||||
{
|
||||
var template = Warehouse.getTemplateByClassId(rt[0], TemplateType.Wrapper);
|
||||
template = Warehouse.getTemplateByClassId(classId, TemplateType.Wrapper);
|
||||
if (template?.definedType != null)
|
||||
dr = new template.getDependencies(self, id, rt[1], rt[2]);
|
||||
else
|
||||
@ -2423,61 +2432,52 @@ export default class DistributedConnection extends IStore {
|
||||
let transmissionType = rt[3] ;
|
||||
let content = rt[4] ;
|
||||
|
||||
self.getTemplate(rt[0]).then(function (tmp) {
|
||||
let initResource = (ok) => {
|
||||
Codec.parse(content, 0, self, newSequence, transmissionType)
|
||||
.reply
|
||||
.then((ar) => {
|
||||
var pvs = new PropertyValueArray();
|
||||
|
||||
// ClassId, ResourceAge, ResourceLink, Content
|
||||
if (resource == null)
|
||||
{
|
||||
let wp = Warehouse.put(id.toString(), dr, self, null, tmp).then(function(ok){
|
||||
|
||||
|
||||
Codec.parse(content, 0, self, transmissionType)
|
||||
.reply
|
||||
.then((ar) => {
|
||||
var pvs = new PropertyValueArray();
|
||||
|
||||
for (var i = 0; i < ar.length; i += 3)
|
||||
for (var i = 0; i < ar.length; i += 3)
|
||||
pvs.push(new PropertyValue(
|
||||
ar[i + 2], ar[i], ar[i + 1]));
|
||||
|
||||
dr._attach(pvs);
|
||||
|
||||
self.resourceRequests.remove(id);
|
||||
reply.trigger(dr);
|
||||
})
|
||||
.error((ex) => reply.triggerError(ex));
|
||||
|
||||
|
||||
});
|
||||
|
||||
wp.error(function(ex){
|
||||
reply.triggerError(ex);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Codec.parse(content, 0, self, transmissionType)
|
||||
.reply
|
||||
.then((ar) => {
|
||||
//print("attached");
|
||||
if (results != null) {
|
||||
var pvs = new PropertyValueArray();
|
||||
|
||||
for (var i = 0; i < ar.length; i += 3)
|
||||
pvs.push(new PropertyValue(
|
||||
ar[i + 2], ar[i], ar[i + 1]));
|
||||
|
||||
dr._attach(pvs);
|
||||
}
|
||||
|
||||
self.resourceRequests.remove(id);
|
||||
reply.trigger(dr);
|
||||
}).error(function(ex) { reply.triggerError(ex)});
|
||||
|
||||
}
|
||||
}).error(function(ex){
|
||||
reply.triggerError(ex);
|
||||
});
|
||||
dr._attach(pvs);
|
||||
|
||||
self.resourceRequests.remove(id);
|
||||
reply.trigger(dr);
|
||||
})
|
||||
.error((ex) => reply.triggerError(ex));
|
||||
};
|
||||
|
||||
if (template == null)
|
||||
{
|
||||
self.getTemplate(rt[0]).then(function (tmp) {
|
||||
// ClassId, ResourceAge, ResourceLink, Content
|
||||
if (resource == null) {
|
||||
Warehouse.put(id.toString(), dr, self, null, tmp).then(function(ok){
|
||||
initResource(ok);
|
||||
}).error(function(ex){
|
||||
reply.triggerError(ex);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
initResource(ok);
|
||||
}
|
||||
}).error(function(ex){
|
||||
reply.triggerError(ex);
|
||||
});
|
||||
} else {
|
||||
if (resource == null) {
|
||||
Warehouse.put(id.toString(), dr, this, null, template)
|
||||
.then(initResource)
|
||||
.error((ex) => reply.triggerError(ex));
|
||||
} else {
|
||||
initResource(resource);
|
||||
}
|
||||
}
|
||||
|
||||
}).error(function(ex){
|
||||
reply.triggerError(ex);
|
||||
});
|
||||
@ -2500,7 +2500,7 @@ export default class DistributedConnection extends IStore {
|
||||
.addDateTime(fromDate).addDateTime(toDate)
|
||||
.done()
|
||||
.then(function (rt) {
|
||||
Codec.parseHistory(rt[0], 0, rt[0].length, resource, self).then(function (history) {
|
||||
Codec.historyParser(rt[0], 0, rt[0].length, resource, self, null).then(function (history) {
|
||||
reply.trigger(history);
|
||||
});
|
||||
});
|
||||
@ -2721,7 +2721,8 @@ export default class DistributedConnection extends IStore {
|
||||
return;
|
||||
}
|
||||
|
||||
DataDeserializer.typedListParser(attributes, 0, attributes.length, this).then(function (attrs) {
|
||||
DataDeserializer.typedListParser(attributes, 0, attributes.length, this, null)
|
||||
.then(function (attrs) {
|
||||
if (r.instance.setAttributes(attrs, clearAttributes))
|
||||
self.sendReply(clearAttributes ? IIPPacketAction.ClearAllAttributes : IIPPacketAction.ClearAttributes,
|
||||
callback)
|
||||
@ -2751,7 +2752,7 @@ export default class DistributedConnection extends IStore {
|
||||
let dataType = ar[0];
|
||||
let data = ar[1];
|
||||
|
||||
Codec.parse(data, 0, self, dataType).reply.then((resources) => {
|
||||
Codec.parse(data, 0, self, null, dataType).reply.then((resources) => {
|
||||
rt.trigger(resources);
|
||||
})
|
||||
.error((ex) => rt.triggerError(ex));
|
||||
@ -2775,7 +2776,7 @@ export default class DistributedConnection extends IStore {
|
||||
|
||||
let dataType = ar[0] ;
|
||||
let data = ar[1];
|
||||
Codec.parse(data, 0, self, dataType).reply.then((resources) => {
|
||||
Codec.parse(data, 0, self, null, dataType).reply.then((resources) => {
|
||||
rt.trigger(resources);
|
||||
})
|
||||
.error((ex) => rt.triggerError(ex));
|
||||
@ -2846,7 +2847,7 @@ export default class DistributedConnection extends IStore {
|
||||
let dataType = ar[0];
|
||||
let data = ar[1];
|
||||
|
||||
Codec.parse(data, 0, self, dataType).reply.then((st) => {
|
||||
Codec.parse(data, 0, self, null, dataType).reply.then((st) => {
|
||||
resource.instance?.setAttributes(st);
|
||||
rt.trigger(st);
|
||||
})
|
||||
@ -2867,7 +2868,7 @@ export default class DistributedConnection extends IStore {
|
||||
let dataType = ar[0] ;
|
||||
let data = ar[1] ;
|
||||
|
||||
Codec.parse(data, 0, self, dataType).reply
|
||||
Codec.parse(data, 0, self, null, dataType).reply
|
||||
.then((st) => {
|
||||
resource.instance?.setAttributes(st);
|
||||
|
||||
|
@ -7,7 +7,7 @@ export default class PropertyModificationInfo {
|
||||
return this.propertyTemplate.name;
|
||||
}
|
||||
|
||||
PropertyModificationInfo(
|
||||
constructor(
|
||||
resource, propertyTemplate, value, age) {
|
||||
this.resource = resource;
|
||||
this.propertyTemplate = propertyTemplate;
|
||||
|
@ -545,7 +545,7 @@ export default class TypeTemplate {
|
||||
|
||||
offset += dt.size;
|
||||
|
||||
let parsed = Codec.parse(data, offset, null);
|
||||
let parsed = Codec.parse(data, offset, null, null);
|
||||
|
||||
offset += parsed.size;
|
||||
|
||||
|
@ -47,7 +47,9 @@ import { Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Float32, Floa
|
||||
import Record from '../Data/Record.js';
|
||||
import TypedMap from '../Data/TypedMap.js';
|
||||
import {RepresentationType, RepresentationTypeIdentifier} from '../Data/RepresentationType.js';
|
||||
import FactoryEntry from './FactoryEntry.js'; './FactoryEntry.js';
|
||||
import FactoryEntry from './FactoryEntry.js';
|
||||
import IEnum from '../Data/IEnum.js';
|
||||
|
||||
export class WH extends IEventHandler
|
||||
{
|
||||
constructor()
|
||||
@ -328,6 +330,8 @@ export class WH extends IEventHandler
|
||||
templateType = TemplateType.Resource;
|
||||
else if (type.prototype instanceof IRecord)
|
||||
templateType = TemplateType.Record;
|
||||
else if (type.prototype instanceof IEnum)
|
||||
templateType = TemplateType.Enum;
|
||||
else
|
||||
return null;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user