mirror of
https://github.com/esiur/esiur-js.git
synced 2025-05-06 12:32:58 +00:00
Rename
This commit is contained in:
parent
7d2bcc60f7
commit
fb6276d6e5
@ -1,4 +1,4 @@
|
|||||||
# Esiur.JS
|
# Esyur.JS
|
||||||
Esiur Library for Javascript
|
Esyur Library for Javascript
|
||||||
|
|
||||||
# Usage
|
# Usage
|
@ -1,5 +1,5 @@
|
|||||||
exports.printMsg = function() {
|
exports.printMsg = function() {
|
||||||
console.log("Esiur 1.1");
|
console.log("Esyur 1.1");
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { wh };
|
module.exports = { wh };
|
||||||
|
1
src/.gitignore
vendored
Normal file
1
src/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
node_modules/
|
@ -36,7 +36,7 @@ export default class AsyncException extends Error
|
|||||||
|
|
||||||
raise(type, code, message)
|
raise(type, code, message)
|
||||||
{
|
{
|
||||||
this.type = (type == 0 ? "Management" : "Execusion");
|
this.type = type;
|
||||||
this.code = code;
|
this.code = code;
|
||||||
|
|
||||||
if (type == 0)
|
if (type == 0)
|
||||||
@ -56,6 +56,6 @@ export default class AsyncException extends Error
|
|||||||
|
|
||||||
toString()
|
toString()
|
||||||
{
|
{
|
||||||
return this.type + " (" + this.code + ") : " + this.message;
|
return (this.type == 0 ? "Management" : "Exception") + " (" + this.code + ") : " + this.message;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -30,13 +30,21 @@ import AsyncException from './AsyncException.js';
|
|||||||
|
|
||||||
export default class AsyncReply extends Promise
|
export default class AsyncReply extends Promise
|
||||||
{
|
{
|
||||||
then(callback)
|
then(callback, onError)
|
||||||
{
|
{
|
||||||
this.callbacks.push(callback);
|
if (callback != undefined)
|
||||||
|
{
|
||||||
if (this.ready)
|
this.callbacks.push(callback);
|
||||||
callback(this.result, this);
|
|
||||||
|
if (this.ready)
|
||||||
|
callback(this.result, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (onError != undefined)
|
||||||
|
{
|
||||||
|
this.error(onError);
|
||||||
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,11 +54,6 @@ export default class AsyncReply extends Promise
|
|||||||
this.then(callback);
|
this.then(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Alias for error()
|
|
||||||
catch(callback)
|
|
||||||
{
|
|
||||||
return this.error(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
error(callback)
|
error(callback)
|
||||||
{
|
{
|
||||||
@ -103,7 +106,7 @@ export default class AsyncReply extends Promise
|
|||||||
this.exception.raise(type, code, message);
|
this.exception.raise(type, code, message);
|
||||||
|
|
||||||
if (this.errorCallbacks.length == 0)
|
if (this.errorCallbacks.length == 0)
|
||||||
throw this.exception;
|
throw this.exception;
|
||||||
else
|
else
|
||||||
for(var i = 0; i < this.errorCallbacks.length; i++)
|
for(var i = 0; i < this.errorCallbacks.length; i++)
|
||||||
this.errorCallbacks[i](this.exception, this);
|
this.errorCallbacks[i](this.exception, this);
|
||||||
|
@ -200,7 +200,7 @@ export default class Codec {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static parseResource(data, offset) {
|
static parseResource(data, offset) {
|
||||||
return Warehouse.get(data.getUint32(offset));
|
return Warehouse.getById(data.getUint32(offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
static parseDistributedResource(data, offset, connection) {
|
static parseDistributedResource(data, offset, connection) {
|
||||||
@ -210,7 +210,7 @@ export default class Codec {
|
|||||||
// find the object
|
// find the object
|
||||||
var iid = data.getUint32(offset);
|
var iid = data.getUint32(offset);
|
||||||
|
|
||||||
return connection.fetch(iid);// Warehouse.Get(iid);
|
return connection.fetch(iid);// Warehouse.getById(iid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -241,7 +241,7 @@ export default class Codec {
|
|||||||
previous = new AsyncReply(null);
|
previous = new AsyncReply(null);
|
||||||
else if (result == ResourceComparisonResult.Local)
|
else if (result == ResourceComparisonResult.Local)
|
||||||
{
|
{
|
||||||
previous = Warehouse.get(data.getUint32(offset));
|
previous = Warehouse.getById(data.getUint32(offset));
|
||||||
offset += 4;
|
offset += 4;
|
||||||
}
|
}
|
||||||
else if (result == ResourceComparisonResult.Distributed)
|
else if (result == ResourceComparisonResult.Distributed)
|
||||||
@ -269,7 +269,7 @@ export default class Codec {
|
|||||||
}
|
}
|
||||||
else if (result == ResourceComparisonResult.Local)
|
else if (result == ResourceComparisonResult.Local)
|
||||||
{
|
{
|
||||||
current = Warehouse.get(data.getUint32(offset));
|
current = Warehouse.getById(data.getUint32(offset));
|
||||||
offset += 4;
|
offset += 4;
|
||||||
}
|
}
|
||||||
else if (result == ResourceComparisonResult.Distributed)
|
else if (result == ResourceComparisonResult.Distributed)
|
||||||
@ -766,7 +766,7 @@ static isLocalResource(resource, connection) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static getDataType(value) {
|
static getDataType(value, connection) {
|
||||||
switch (typeof value) {
|
switch (typeof value) {
|
||||||
case "number":
|
case "number":
|
||||||
// float or ?
|
// float or ?
|
||||||
|
@ -68,9 +68,17 @@ import { ResourceTrigger } from '../../Resource/IResource.js';
|
|||||||
|
|
||||||
export default class DistributedConnection extends IStore {
|
export default class DistributedConnection extends IStore {
|
||||||
|
|
||||||
|
|
||||||
send(data) {
|
send(data) {
|
||||||
//console.log("Send", data.length);
|
|
||||||
this.socket.send(data.buffer);
|
if (this.holdSending)
|
||||||
|
{
|
||||||
|
//console.log("hold ", data.length);
|
||||||
|
this.sendBuffer.writeAll(data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
//console.log("Send", data.length);
|
||||||
|
this.socket.send(data.buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
sendParams(doneReply) {
|
sendParams(doneReply) {
|
||||||
@ -516,6 +524,25 @@ export default class DistributedConnection extends IStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hold()
|
||||||
|
{
|
||||||
|
this.holdSending = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
unhold()
|
||||||
|
{
|
||||||
|
if (this.holdSending)
|
||||||
|
{
|
||||||
|
var msg = this.sendBuffer.read();
|
||||||
|
|
||||||
|
if (msg == null || msg.length == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this.socket.send(msg);
|
||||||
|
this.holdSending = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
trigger(trigger)
|
trigger(trigger)
|
||||||
{
|
{
|
||||||
if (trigger == ResourceTrigger.Open)
|
if (trigger == ResourceTrigger.Open)
|
||||||
@ -576,9 +603,10 @@ export default class DistributedConnection extends IStore {
|
|||||||
|
|
||||||
self.lastAction = new Date();
|
self.lastAction = new Date();
|
||||||
|
|
||||||
|
self.hold();
|
||||||
while (this.networkBuffer.available > 0 && !this.networkBuffer.protected)
|
while (this.networkBuffer.available > 0 && !this.networkBuffer.protected)
|
||||||
self.receive(this.networkBuffer);
|
self.receive(this.networkBuffer);
|
||||||
|
self.unhold();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -873,7 +901,7 @@ export default class DistributedConnection extends IStore {
|
|||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
|
|
||||||
Warehouse.get(resourceId).then(function (r) {
|
Warehouse.getById(resourceId).then(function (r) {
|
||||||
if (r != null) {
|
if (r != null) {
|
||||||
|
|
||||||
if (r.instance.applicable(self.session, ActionType.Attach, null) == Ruling.Denied)
|
if (r.instance.applicable(self.session, ActionType.Attach, null) == Ruling.Denied)
|
||||||
@ -916,7 +944,7 @@ export default class DistributedConnection extends IStore {
|
|||||||
IIPRequestReattachResource(callback, resourceId, resourceAge) {
|
IIPRequestReattachResource(callback, resourceId, resourceAge) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
Warehouse.get(resourceId).then(function (r) {
|
Warehouse.getById(resourceId).then(function (r) {
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
r.instance.on("ResourceEventOccurred", self.instance_eventOccurred, self);
|
r.instance.on("ResourceEventOccurred", self.instance_eventOccurred, self);
|
||||||
r.instance.on("ResourceModified", self.instance_propertyModified, self);
|
r.instance.on("ResourceModified", self.instance_propertyModified, self);
|
||||||
@ -937,7 +965,7 @@ export default class DistributedConnection extends IStore {
|
|||||||
IIPRequestDetachResource(callback, resourceId) {
|
IIPRequestDetachResource(callback, resourceId) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
Warehouse.get(resourceId).then(function (r) {
|
Warehouse.getById(resourceId).then(function (r) {
|
||||||
if (r != null) {
|
if (r != null) {
|
||||||
r.instance.off("ResourceEventOccurred", self.instance_eventOccurred);
|
r.instance.off("ResourceEventOccurred", self.instance_eventOccurred);
|
||||||
r.instance.off("ResourceModified", self.instance_propertyModified);
|
r.instance.off("ResourceModified", self.instance_propertyModified);
|
||||||
@ -955,7 +983,7 @@ export default class DistributedConnection extends IStore {
|
|||||||
|
|
||||||
IIPRequestCreateResource(callback, storeId, parentId, content) {
|
IIPRequestCreateResource(callback, storeId, parentId, content) {
|
||||||
var self = this;
|
var self = this;
|
||||||
Warehouse.get(storeId).then(function(store)
|
Warehouse.getById(storeId).then(function(store)
|
||||||
{
|
{
|
||||||
if (store == null)
|
if (store == null)
|
||||||
{
|
{
|
||||||
@ -976,7 +1004,7 @@ export default class DistributedConnection extends IStore {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Warehouse.get(parentId).then(function(parent)
|
Warehouse.getById(parentId).then(function(parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
// check security
|
// check security
|
||||||
@ -1039,7 +1067,7 @@ export default class DistributedConnection extends IStore {
|
|||||||
|
|
||||||
IIPRequestDeleteResource(callback, resourceId) {
|
IIPRequestDeleteResource(callback, resourceId) {
|
||||||
var self = this;
|
var self = this;
|
||||||
Warehouse.get(resourceId).then(function(r)
|
Warehouse.getById(resourceId).then(function(r)
|
||||||
{
|
{
|
||||||
if (r == null)
|
if (r == null)
|
||||||
{
|
{
|
||||||
@ -1096,7 +1124,7 @@ export default class DistributedConnection extends IStore {
|
|||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
Warehouse.get(resourceId).then(function (r) {
|
Warehouse.getById(resourceId).then(function (r) {
|
||||||
if (r != null)
|
if (r != null)
|
||||||
self.sendReply(IIPPacketAction.TemplateFromResourceId, callback)
|
self.sendReply(IIPPacketAction.TemplateFromResourceId, callback)
|
||||||
.addUint32(r.instance.template.content.length)
|
.addUint32(r.instance.template.content.length)
|
||||||
@ -1113,7 +1141,7 @@ export default class DistributedConnection extends IStore {
|
|||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
Warehouse.get(resourceId).then(function (r) {
|
Warehouse.getById(resourceId).then(function (r) {
|
||||||
if (r != null) {
|
if (r != null) {
|
||||||
Codec.parseVarArray(content, 0, content.length, self).then(function (args) {
|
Codec.parseVarArray(content, 0, content.length, self).then(function (args) {
|
||||||
var ft = r.instance.template.getFunctionTemplateByIndex(index);
|
var ft = r.instance.template.getFunctionTemplateByIndex(index);
|
||||||
@ -1194,7 +1222,7 @@ export default class DistributedConnection extends IStore {
|
|||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
Warehouse.get(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);
|
||||||
@ -1282,7 +1310,7 @@ export default class DistributedConnection extends IStore {
|
|||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
Warehouse.get(resourceId).then(function (r) {
|
Warehouse.getById(resourceId).then(function (r) {
|
||||||
if (r != null) {
|
if (r != null) {
|
||||||
var pt = r.instance.template.getFunctionTemplateByIndex(index);
|
var pt = r.instance.template.getFunctionTemplateByIndex(index);
|
||||||
if (pt != null) {
|
if (pt != null) {
|
||||||
@ -1312,7 +1340,7 @@ export default class DistributedConnection extends IStore {
|
|||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
Warehouse.get(resourceId).then(function (r) {
|
Warehouse.getById(resourceId).then(function (r) {
|
||||||
if (r != null) {
|
if (r != null) {
|
||||||
var pt = r.instance.template.getFunctionTemplateByIndex(index);
|
var pt = r.instance.template.getFunctionTemplateByIndex(index);
|
||||||
if (pt != null) {
|
if (pt != null) {
|
||||||
@ -1343,7 +1371,7 @@ export default class DistributedConnection extends IStore {
|
|||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
Warehouse.get(resourceId).then(function (r) {
|
Warehouse.getById(resourceId).then(function (r) {
|
||||||
if (r != null) {
|
if (r != null) {
|
||||||
|
|
||||||
|
|
||||||
@ -1399,7 +1427,7 @@ export default class DistributedConnection extends IStore {
|
|||||||
IIPRequestInquireResourceHistory(callback, resourceId, fromDate, toDate)
|
IIPRequestInquireResourceHistory(callback, resourceId, fromDate, toDate)
|
||||||
{
|
{
|
||||||
var self = this;
|
var self = this;
|
||||||
Warehouse.get(resourceId).then(function(r)
|
Warehouse.getById(resourceId).then(function(r)
|
||||||
{
|
{
|
||||||
if (r != null)
|
if (r != null)
|
||||||
{
|
{
|
||||||
@ -1678,7 +1706,7 @@ export default class DistributedConnection extends IStore {
|
|||||||
IIPRequestAddChild(callback, parentId, childId)
|
IIPRequestAddChild(callback, parentId, childId)
|
||||||
{
|
{
|
||||||
var self = this;
|
var self = this;
|
||||||
Warehouse.get(parentId).then(function(parent)
|
Warehouse.getById(parentId).then(function(parent)
|
||||||
{
|
{
|
||||||
if (parent == null)
|
if (parent == null)
|
||||||
{
|
{
|
||||||
@ -1686,7 +1714,7 @@ export default class DistributedConnection extends IStore {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Warehouse.get(childId).then(function(child)
|
Warehouse.getById(childId).then(function(child)
|
||||||
{
|
{
|
||||||
if (child == null)
|
if (child == null)
|
||||||
{
|
{
|
||||||
@ -1720,7 +1748,7 @@ export default class DistributedConnection extends IStore {
|
|||||||
{
|
{
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
Warehouse.get(parentId).then(function(parent)
|
Warehouse.getById(parentId).then(function(parent)
|
||||||
{
|
{
|
||||||
if (parent == null)
|
if (parent == null)
|
||||||
{
|
{
|
||||||
@ -1728,7 +1756,7 @@ export default class DistributedConnection extends IStore {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Warehouse.get(childId).then(function(child)
|
Warehouse.getById(childId).then(function(child)
|
||||||
{
|
{
|
||||||
if (child == null)
|
if (child == null)
|
||||||
{
|
{
|
||||||
@ -1761,7 +1789,7 @@ export default class DistributedConnection extends IStore {
|
|||||||
IIPRequestRenameResource(callback, resourceId, name)
|
IIPRequestRenameResource(callback, resourceId, name)
|
||||||
{
|
{
|
||||||
var self = this;
|
var self = this;
|
||||||
Warehouse.get(resourceId).then(function(resource)
|
Warehouse.getById(resourceId).then(function(resource)
|
||||||
{
|
{
|
||||||
if (resource == null)
|
if (resource == null)
|
||||||
{
|
{
|
||||||
@ -1784,7 +1812,7 @@ export default class DistributedConnection extends IStore {
|
|||||||
IIPRequestResourceChildren(callback, resourceId)
|
IIPRequestResourceChildren(callback, resourceId)
|
||||||
{
|
{
|
||||||
var self = this;
|
var self = this;
|
||||||
Warehouse.get(resourceId).then(function(resource)
|
Warehouse.getById(resourceId).then(function(resource)
|
||||||
{
|
{
|
||||||
if (resource == null)
|
if (resource == null)
|
||||||
{
|
{
|
||||||
@ -1803,7 +1831,7 @@ export default class DistributedConnection extends IStore {
|
|||||||
{
|
{
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
Warehouse.get(resourceId).then(function(resource)
|
Warehouse.getById(resourceId).then(function(resource)
|
||||||
{
|
{
|
||||||
if (resource == null)
|
if (resource == null)
|
||||||
{
|
{
|
||||||
@ -1819,7 +1847,7 @@ export default class DistributedConnection extends IStore {
|
|||||||
|
|
||||||
IIPRequestClearAttributes(callback, resourceId, attributes, all = false)
|
IIPRequestClearAttributes(callback, resourceId, attributes, all = false)
|
||||||
{
|
{
|
||||||
Warehouse.get(resourceId).then(function(r)
|
Warehouse.getById(resourceId).then(function(r)
|
||||||
{
|
{
|
||||||
if (r == null)
|
if (r == null)
|
||||||
{
|
{
|
||||||
@ -1851,7 +1879,7 @@ export default class DistributedConnection extends IStore {
|
|||||||
{
|
{
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
Warehouse.get(resourceId).then(function(r)
|
Warehouse.getById(resourceId).then(function(r)
|
||||||
{
|
{
|
||||||
if (r == null)
|
if (r == null)
|
||||||
{
|
{
|
||||||
|
@ -59,7 +59,8 @@ export default class IIPPacket
|
|||||||
{
|
{
|
||||||
if (offset + needed > ends)
|
if (offset + needed > ends)
|
||||||
{
|
{
|
||||||
this.dataLengthNeeded = needed - (ends - this.originalOffset);
|
this.dataLengthNeeded = needed - (ends - offset);
|
||||||
|
// this.dataLengthNeeded = needed - (ends - this.originalOffset);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -54,7 +54,7 @@ export default class IResource extends IDestructible
|
|||||||
static getTemplate()
|
static getTemplate()
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
namespace: "Esiur",
|
namespace: "Esyur",
|
||||||
properties: [],
|
properties: [],
|
||||||
functions: [],
|
functions: [],
|
||||||
events: []
|
events: []
|
||||||
|
@ -60,82 +60,78 @@ export class WH extends IEventHandler
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getById(id)
|
||||||
|
{
|
||||||
|
return new AsyncReply(this.resources.item(id));
|
||||||
|
}
|
||||||
|
|
||||||
get(id, attributes = null, parent = null, manager = null)
|
get(id, attributes = null, parent = null, manager = null)
|
||||||
{
|
{
|
||||||
if (Number.isInteger(id))
|
|
||||||
|
var p = id.split('/');
|
||||||
|
var res = null;
|
||||||
|
|
||||||
|
for(var s = 0; s < this.stores.length; s++)
|
||||||
{
|
{
|
||||||
//if (Warehouse.resources.contains(id))
|
var d = this.stores.at(s);
|
||||||
return new AsyncReply(this.resources.item(id));
|
if (p[0] == d.instance.name)
|
||||||
//else
|
|
||||||
// return null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var p = id.split('/');
|
|
||||||
var res = null;
|
|
||||||
|
|
||||||
for(var s = 0; s < this.stores.length; s++)
|
|
||||||
{
|
{
|
||||||
var d = this.stores.at(s);
|
var i = 1;
|
||||||
if (p[0] == d.instance.name)
|
res = d;
|
||||||
|
while(p.length > i)
|
||||||
{
|
{
|
||||||
var i = 1;
|
var si = i;
|
||||||
res = d;
|
|
||||||
while(p.length > i)
|
|
||||||
{
|
|
||||||
var si = i;
|
|
||||||
|
|
||||||
for (var r = 0; r < res.instance.children.length; r++)
|
for (var r = 0; r < res.instance.children.length; r++)
|
||||||
if (res.instance.children.item(r).instance.name == p[i])
|
if (res.instance.children.item(r).instance.name == p[i])
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
res = res.instance.children.item(r);
|
res = res.instance.children.item(r);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (si == i)
|
if (si == i)
|
||||||
// not found, ask the store
|
// not found, ask the store
|
||||||
return d.get(id.substring(p[0].length + 1));
|
return d.get(id.substring(p[0].length + 1));
|
||||||
}
|
|
||||||
|
|
||||||
return new AsyncReply(res);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Should we create a new store ?
|
|
||||||
if (id.includes("://"))
|
|
||||||
{
|
|
||||||
var url = id.split("://", 2);
|
|
||||||
var hostname = url[1].split("/", 2)[0];
|
|
||||||
var pathname = url[1].split("/").splice(1).join("/");
|
|
||||||
var handler;
|
|
||||||
|
|
||||||
var rt = new AsyncReply();
|
|
||||||
var self = this;
|
|
||||||
|
|
||||||
if (handler = this.protocols.item(url[0]))
|
|
||||||
{
|
|
||||||
var store = handler();
|
|
||||||
this.put(store, url[0] + "://" + hostname, null, parent, null, 0, manager, attributes);
|
|
||||||
store.trigger(ResourceTrigger.Open).then(x=>{
|
|
||||||
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;
|
return new AsyncReply(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Should we create a new store ?
|
||||||
|
if (id.includes("://"))
|
||||||
|
{
|
||||||
|
var url = id.split("://", 2);
|
||||||
|
var hostname = url[1].split("/", 2)[0];
|
||||||
|
var pathname = url[1].split("/").splice(1).join("/");
|
||||||
|
var handler;
|
||||||
|
|
||||||
|
var rt = new AsyncReply();
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
if (handler = this.protocols.item(url[0]))
|
||||||
|
{
|
||||||
|
var store = handler();
|
||||||
|
this.put(store, url[0] + "://" + hostname, null, parent, null, 0, manager, attributes);
|
||||||
|
store.trigger(ResourceTrigger.Open).then(x=>{
|
||||||
|
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 new AsyncReply(null);
|
return rt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return new AsyncReply(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
2
src/package-lock.json
generated
2
src/package-lock.json
generated
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "esiur",
|
"name": "esyur",
|
||||||
"version": "1.2.2",
|
"version": "1.2.2",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
{
|
{
|
||||||
"name": "esiur",
|
"name": "Esyur",
|
||||||
"version": "1.3.0",
|
"version": "1.3.0",
|
||||||
"description": "Distributed Object Framework",
|
"description": "Distributed Object Framework",
|
||||||
"main": "esiur.js",
|
"main": "Esyur.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/esiur/esiur-js.git"
|
"url": "git+https://github.com/esyur/esyur-js.git"
|
||||||
},
|
},
|
||||||
"author": "Ahmed Zamil",
|
"author": "Ahmed Zamil",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/esiur/esiur-js/issues"
|
"url": "https://github.com/esyur/esyur-js/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/esiur/esiur-js#readme",
|
"homepage": "https://github.com/esyur/esyur-js#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ws": "^6.2.0"
|
"ws": "^6.2.0"
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,8 @@ class MyStore extends IStore
|
|||||||
|
|
||||||
async function load()
|
async function load()
|
||||||
{
|
{
|
||||||
window.x = await wh.get("iip://localhost:5001/db/my", {username: "demo", password: "1234"});
|
// window.x = await wh.get("iip://localhost:5001/db/my", {username: "demo", password: "1234"});
|
||||||
|
window.x = await wh.get("iip://chat.go.iq:5001/sys/hd", {username: "admin", password: "delta"});
|
||||||
|
|
||||||
console.log(window.x);
|
console.log(window.x);
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
|
|
||||||
<script src="/iui-js/iui.js"></script>
|
<script src="/iui-js/iui.js"></script>
|
||||||
|
|
||||||
<script src="viewers/Esiur.Stores.MemoryStore.js"></script>
|
<script src="viewers/Esyur.Stores.MemoryStore.js"></script>
|
||||||
|
|
||||||
<script src="js/browser.js"></script>
|
<script src="js/browser.js"></script>
|
||||||
<script src="js/app.js"></script>
|
<script src="js/app.js"></script>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
class Esiur_Stores_MemoryStore extends IUIWidget
|
class Esyur_Stores_MemoryStore extends IUIWidget
|
||||||
{
|
{
|
||||||
constuctor()
|
constuctor()
|
||||||
{
|
{
|
||||||
@ -6,4 +6,4 @@ class Esiur_Stores_MemoryStore extends IUIWidget
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IUI.module("Esiur.Stores.MemoryStore", Esiur_Stores_MemoryStore);
|
IUI.module("Esyur.Stores.MemoryStore", Esyur_Stores_MemoryStore);
|
Loading…
x
Reference in New Issue
Block a user