mirror of
https://github.com/esiur/esiur-js.git
synced 2025-05-06 12:32:58 +00:00
1.3.5
This commit is contained in:
parent
019a09d621
commit
2a99d4c04a
@ -298,7 +298,7 @@ export default class Codec {
|
|||||||
static composePropertyValueArray(array, connection, prependLength = false)
|
static composePropertyValueArray(array, connection, prependLength = false)
|
||||||
{
|
{
|
||||||
var rt = BL();
|
var rt = BL();
|
||||||
for (var i = 0; i < array.Length; i++)
|
for (var i = 0; i < array.length; i++)
|
||||||
rt.addUint8Array(Codec.composePropertyValue(array[i], connection));
|
rt.addUint8Array(Codec.composePropertyValue(array[i], connection));
|
||||||
if (prependLength)
|
if (prependLength)
|
||||||
rt.addUint32(rt.length, 0);
|
rt.addUint32(rt.length, 0);
|
||||||
@ -647,7 +647,7 @@ export default class Codec {
|
|||||||
rt.addUint8(comparision);
|
rt.addUint8(comparision);
|
||||||
rt.addUint8Array(Codec.composeStructure(structures[0], connection));
|
rt.addUint8Array(Codec.composeStructure(structures[0], connection));
|
||||||
|
|
||||||
for (var i = 1; i < structures.Length; i++) {
|
for (var i = 1; i < structures.length; i++) {
|
||||||
comparision = Codec.compareStructure(structures[i - 1], structures[i], connection);
|
comparision = Codec.compareStructure(structures[i - 1], structures[i], connection);
|
||||||
rt.addUint8(comparision);
|
rt.addUint8(comparision);
|
||||||
|
|
||||||
@ -747,7 +747,7 @@ static isLocalResource(resource, connection) {
|
|||||||
else if (comparsion == ResourceComparisonResult.Distributed)
|
else if (comparsion == ResourceComparisonResult.Distributed)
|
||||||
rt.addUint32(resources[0].instance.id);
|
rt.addUint32(resources[0].instance.id);
|
||||||
|
|
||||||
for (var i = 1; i < resources.Length; i++)
|
for (var i = 1; i < resources.length; i++)
|
||||||
{
|
{
|
||||||
comparsion = Codec.compareResource(resources[i - 1], resources[i], connection);
|
comparsion = Codec.compareResource(resources[i - 1], resources[i], connection);
|
||||||
rt.addUint8(comparsion);
|
rt.addUint8(comparsion);
|
||||||
|
@ -533,13 +533,14 @@ export default class DistributedConnection extends IStore {
|
|||||||
{
|
{
|
||||||
if (this.holdSending)
|
if (this.holdSending)
|
||||||
{
|
{
|
||||||
|
this.holdSending = false;
|
||||||
|
|
||||||
var msg = this.sendBuffer.read();
|
var msg = this.sendBuffer.read();
|
||||||
|
|
||||||
if (msg == null || msg.length == 0)
|
if (msg == null || msg.length == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.socket.send(msg);
|
this.socket.send(msg);
|
||||||
this.holdSending = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -558,17 +559,24 @@ export default class DistributedConnection extends IStore {
|
|||||||
|
|
||||||
this.openReply = new AsyncReply();
|
this.openReply = new AsyncReply();
|
||||||
|
|
||||||
var hostname = this.instance.name.split("://", 2)[1].split("/", 2)[0];
|
//var hostname = this.instance.name.split("://", 2)[1].split("/", 2)[0];
|
||||||
|
|
||||||
// assign domain from hostname if not provided
|
// assign domain from hostname if not provided
|
||||||
domain = domain ? domain : hostname.split(":")[0];
|
|
||||||
|
|
||||||
|
var host = this.instance.name.split(':');
|
||||||
|
|
||||||
|
var address = host[0];
|
||||||
|
var port = parseInt(host[1]);
|
||||||
|
|
||||||
|
domain = domain ? domain : address;
|
||||||
|
|
||||||
this.session.localAuthentication.domain = domain;
|
this.session.localAuthentication.domain = domain;
|
||||||
this.session.localAuthentication.username = username;
|
this.session.localAuthentication.username = username;
|
||||||
|
|
||||||
this.localPassword = DC.stringToBytes(password);
|
this.localPassword = DC.stringToBytes(password);
|
||||||
|
|
||||||
var url = `ws${secure ? 's' : ''}://${hostname}`;
|
var url = `ws${secure ? 's' : ''}://${this.instance.name}`;
|
||||||
|
|
||||||
|
|
||||||
this.debug = debug;
|
this.debug = debug;
|
||||||
@ -1225,7 +1233,7 @@ export default class DistributedConnection extends IStore {
|
|||||||
|
|
||||||
Warehouse.getById(resourceId).then(function (r) {
|
Warehouse.getById(resourceId).then(function (r) {
|
||||||
if (r != null) {
|
if (r != null) {
|
||||||
Codec.parseStructure(content, 0, content.Length, self).then(function (namedArgs) {
|
Codec.parseStructure(content, 0, content.length, self).then(function (namedArgs) {
|
||||||
var ft = r.instance.template.getFunctionTemplateByIndex(index);
|
var ft = r.instance.template.getFunctionTemplateByIndex(index);
|
||||||
if (ft != null) {
|
if (ft != null) {
|
||||||
if (r instanceof DistributedResource) {
|
if (r instanceof DistributedResource) {
|
||||||
@ -1256,7 +1264,7 @@ export default class DistributedConnection extends IStore {
|
|||||||
var pi = ResourceTemplate.getFunctionParameters(fi);
|
var pi = ResourceTemplate.getFunctionParameters(fi);
|
||||||
var args = new Array(pi.length);
|
var args = new Array(pi.length);
|
||||||
|
|
||||||
for (var i = 0; i < pi.Length; i++)
|
for (var i = 0; i < pi.length; i++)
|
||||||
{
|
{
|
||||||
if (namedArgs[pi[i]] !== undefined)
|
if (namedArgs[pi[i]] !== undefined)
|
||||||
args[i] = namedArgs[pi[i]];
|
args[i] = namedArgs[pi[i]];
|
||||||
@ -1894,7 +1902,7 @@ export default class DistributedConnection extends IStore {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Codec.parseStructure(attributes, 0, attributes.Length, this).then(function(attrs) {
|
Codec.parseStructure(attributes, 0, attributes.length, this).then(function(attrs) {
|
||||||
if (r.instance.setAttributes(attrs, clearAttributes))
|
if (r.instance.setAttributes(attrs, clearAttributes))
|
||||||
self.sendReply(clearAttributes ? IIPPacketAction.ClearAllAttributes : IIPPacketAction.ClearAttributes,
|
self.sendReply(clearAttributes ? IIPPacketAction.ClearAllAttributes : IIPPacketAction.ClearAttributes,
|
||||||
callback)
|
callback)
|
||||||
|
@ -65,9 +65,62 @@ export class WH extends IEventHandler
|
|||||||
return new AsyncReply(this.resources.item(id));
|
return new AsyncReply(this.resources.item(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
get(id, attributes = null, parent = null, manager = null)
|
get(path, attributes = null, parent = null, manager = null)
|
||||||
{
|
{
|
||||||
|
var rt = new AsyncReply();
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
// Should we create a new store ?
|
||||||
|
|
||||||
|
if (path.includes("://"))
|
||||||
|
{
|
||||||
|
|
||||||
|
var url = path.split("://", 2);
|
||||||
|
var hostname = url[1].split("/", 2)[0];
|
||||||
|
var pathname = url[1].split("/").splice(1).join("/");
|
||||||
|
|
||||||
|
var handler;
|
||||||
|
|
||||||
|
if (handler = this.protocols.item(url[0]))
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
var store = handler();
|
||||||
|
this.put(store, hostname, null, parent, null, 0, manager, attributes);
|
||||||
|
|
||||||
|
|
||||||
|
store.trigger(ResourceTrigger.Open).then(x => {
|
||||||
|
|
||||||
|
this.warehouseIsOpen = true;
|
||||||
|
|
||||||
|
if (pathname.length > 0 && pathname != "")
|
||||||
|
store.get(pathname).then(r => {
|
||||||
|
rt.trigger(r);
|
||||||
|
}).error(e => rt.triggerError(e));
|
||||||
|
else
|
||||||
|
rt.trigger(store);
|
||||||
|
}).error(e => {
|
||||||
|
rt.triggerError(e);
|
||||||
|
self.remove(store);
|
||||||
|
});
|
||||||
|
|
||||||
|
return rt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.query(path).then(rs =>
|
||||||
|
{
|
||||||
|
if (rs != null && rs.length > 0)
|
||||||
|
rt.trigger(rs[0]);
|
||||||
|
else
|
||||||
|
rt.trigger(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
return rt;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
var p = id.split('/');
|
var p = id.split('/');
|
||||||
var res = null;
|
var res = null;
|
||||||
|
|
||||||
@ -132,6 +185,7 @@ export class WH extends IEventHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new AsyncReply(null);
|
return new AsyncReply(null);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -287,10 +341,56 @@ export class WH extends IEventHandler
|
|||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
|
|
||||||
query(path)
|
async query(path)
|
||||||
{
|
{
|
||||||
var p = path.split('/');
|
//var p = path.split('/');
|
||||||
return new AsyncReply(this._qureyIn(p, 0, this.stores));
|
//return new AsyncReply(this._qureyIn(p, 0, this.stores));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var rt = new AsyncReply();
|
||||||
|
|
||||||
|
var p = path.trim().split('/');
|
||||||
|
var resource;
|
||||||
|
|
||||||
|
for(var i = 0; i < this.stores.length; i++)
|
||||||
|
{
|
||||||
|
let store = this.stores.at(i);
|
||||||
|
|
||||||
|
if (p[0] == store.instance.name)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (p.length == 1)
|
||||||
|
return [store];
|
||||||
|
|
||||||
|
|
||||||
|
var res = await store.get(p.splice(1).join("/"));
|
||||||
|
if (res != null)
|
||||||
|
return [res];
|
||||||
|
|
||||||
|
|
||||||
|
resource = store;
|
||||||
|
for (var i = 1; i < p.length; i++)
|
||||||
|
{
|
||||||
|
var children = await resource.instance.children.list.filter(x=>x.instance.name == p[i]);// <IResource>(p[i]);
|
||||||
|
if (children.length > 0)
|
||||||
|
{
|
||||||
|
if (i == p.length - 1)
|
||||||
|
return children;
|
||||||
|
else
|
||||||
|
resource = children[0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "esyur",
|
"name": "esyur",
|
||||||
"version": "1.3.2",
|
"version": "1.3.5",
|
||||||
"description": "Distributed Object Framework",
|
"description": "Distributed Object Framework",
|
||||||
"main": "esyur.js",
|
"main": "esyur.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user