mirror of
https://github.com/esiur/esiur-js.git
synced 2025-05-06 04:22:58 +00:00
ES6 modules
This commit is contained in:
parent
1e522af044
commit
fdfa690b23
@ -5,4 +5,4 @@ exports.printMsg = function() {
|
||||
module.exports = { Warehouse, DistributedConnection};
|
||||
|
||||
|
||||
var WebSocket = require('ws')
|
||||
let WebSocket = require('ws')
|
||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "esiur",
|
||||
"version": "1.0.0",
|
||||
"version": "1.2.2",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -26,7 +26,10 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
class AutoList extends IEventHandler
|
||||
import IEventHandler from '../Engine/IEventHandler.js';
|
||||
import IDestructible from '../Engine/IDestructible.js';
|
||||
|
||||
export default class AutoList extends IEventHandler
|
||||
{
|
||||
constructor()
|
||||
{
|
@ -25,8 +25,10 @@
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
import IEventHandler from '../Engine/IEventHandler.js';
|
||||
import IDestructible from '../Engine/IDestructible.js';
|
||||
|
||||
class AutoMap extends IEventHandler
|
||||
export default class AutoMap extends IEventHandler
|
||||
{
|
||||
constructor()
|
||||
{
|
@ -26,11 +26,10 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
function BL(){
|
||||
return new BinaryList();
|
||||
};
|
||||
import DataType from './DataType.js';
|
||||
import DC from './DataConverter.js';
|
||||
|
||||
class BinaryList
|
||||
export default class BinaryList
|
||||
{
|
||||
|
||||
constructor()
|
@ -26,26 +26,13 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
const ResourceComparisonResult =
|
||||
{
|
||||
Null: 0,
|
||||
Distributed: 1,
|
||||
Local: 2,
|
||||
Same: 3
|
||||
};
|
||||
import DataType from './DataType.js';
|
||||
import ResourceComparisonResult from './ResourceComparisionResult.js';
|
||||
import StructureComparisonResult from './StructureComparisonResult.js';
|
||||
|
||||
const StructureComparisonResult =
|
||||
{
|
||||
Null: 0,
|
||||
Structure: 1,
|
||||
StructureSameKeys: 2,
|
||||
StructureSameTypes: 3,
|
||||
Same: 4
|
||||
};
|
||||
|
||||
class Codec {
|
||||
export default class Codec {
|
||||
|
||||
|
||||
static parse(data, offset, sizeObject, connection, dataType = DataType.Unspecified) {
|
||||
|
||||
var size;
|
@ -24,12 +24,15 @@
|
||||
* Created by Ahmed Zamil on 25/07/2017.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
"use strict";
|
||||
|
||||
const UNIX_EPOCH = 621355968000000000;
|
||||
const TWO_PWR_32 = (1 << 16) * (1 << 16);
|
||||
import BinaryList from './BinaryList.js';
|
||||
import Guid from './Guid.js';
|
||||
|
||||
class DC extends Uint8Array// extends DataView // Data Converter
|
||||
export const UNIX_EPOCH = 621355968000000000;
|
||||
export const TWO_PWR_32 = (1 << 16) * (1 << 16);
|
||||
|
||||
export default class DC extends Uint8Array
|
||||
{
|
||||
constructor(bufferOrSize) {
|
||||
super(bufferOrSize);
|
||||
@ -499,4 +502,8 @@ class DC extends Uint8Array// extends DataView // Data Converter
|
||||
}
|
||||
}
|
||||
|
||||
export function BL(){
|
||||
return new BinaryList();
|
||||
};
|
||||
|
||||
export {DC};
|
@ -26,7 +26,7 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
const DataType =
|
||||
export default //const DataType =
|
||||
{
|
||||
Void: 0x0,
|
||||
//Variant,
|
@ -26,7 +26,7 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
class Guid
|
||||
export default class Guid
|
||||
{
|
||||
constructor(dc)
|
||||
{
|
@ -25,8 +25,9 @@
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
import IDestructible from '../Engine/IDestructible.js';
|
||||
|
||||
class KeyList
|
||||
export default class KeyList
|
||||
{
|
||||
constructor()
|
||||
{
|
@ -26,7 +26,7 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
class NotModified
|
||||
export default class NotModified
|
||||
{
|
||||
|
||||
}
|
@ -26,7 +26,7 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
class PropertyValue
|
||||
export default class PropertyValue
|
||||
{
|
||||
constructor(value, age, date)
|
||||
{
|
@ -26,7 +26,7 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
class ResourceArray extends Array
|
||||
export default class ResourceArray extends Array
|
||||
{
|
||||
push(value)
|
||||
{
|
7
src/Data/ResourceComparisionResult.js
Normal file
7
src/Data/ResourceComparisionResult.js
Normal file
@ -0,0 +1,7 @@
|
||||
export default // const ResourceComparisonResult =
|
||||
{
|
||||
Null: 0,
|
||||
Distributed: 1,
|
||||
Local: 2,
|
||||
Same: 3
|
||||
};
|
@ -26,7 +26,7 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
class Structure
|
||||
export default class Structure
|
||||
{
|
||||
getKeys() {
|
||||
var rt = [];
|
@ -26,7 +26,8 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
class StructureArray extends Array
|
||||
|
||||
export default class StructureArray extends Array
|
||||
{
|
||||
push(value)
|
||||
{
|
9
src/Data/StructureComparisonResult.js
Normal file
9
src/Data/StructureComparisonResult.js
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
export default //const StructureComparisonResult =
|
||||
{
|
||||
Null: 0,
|
||||
Structure: 1,
|
||||
StructureSameKeys: 2,
|
||||
StructureSameTypes: 3,
|
||||
Same: 4
|
||||
};
|
@ -25,7 +25,9 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
class AsyncBag extends AsyncReply
|
||||
import AsyncReply from './AsyncReply.js';
|
||||
|
||||
export default class AsyncBag extends AsyncReply
|
||||
{
|
||||
constructor() {
|
||||
super();
|
@ -24,39 +24,10 @@
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
const ExceptionCode =
|
||||
{
|
||||
HostNotReachable: 0,
|
||||
AccessDenied: 1,
|
||||
ResourceNotFound: 2,
|
||||
AttachDenied: 3,
|
||||
InvalidMethod: 4,
|
||||
InvokeDenied: 5,
|
||||
CreateDenied: 6,
|
||||
AddParentDenied: 7,
|
||||
AddChildDenied: 8,
|
||||
ViewAttributeDenied: 9,
|
||||
UpdateAttributeDenied: 10,
|
||||
StoreNotFound: 11,
|
||||
ParentNotFound: 12,
|
||||
ChildNotFound: 13,
|
||||
ResourceIsNotStore: 14,
|
||||
DeleteDenied: 15,
|
||||
DeleteFailed: 16,
|
||||
UpdateAttributeFailed: 17,
|
||||
GetAttributesFailed: 18,
|
||||
ClearAttributesFailed: 19,
|
||||
TemplateNotFound: 20,
|
||||
RenameDenied: 21,
|
||||
ClassNotFound: 22,
|
||||
MethodNotFound: 23,
|
||||
PropertyNotFound: 24,
|
||||
SetPropertyDenied: 25,
|
||||
ReadOnlyProperty: 26
|
||||
};
|
||||
import ExceptionCode from './ExceptionCode.js';
|
||||
|
||||
class AsyncException extends Error
|
||||
{
|
||||
export default class AsyncException extends Error
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
super();
|
@ -23,9 +23,11 @@
|
||||
* Created by Ahmed Zamil on 25/07/2017.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
"use strict";
|
||||
|
||||
class AsyncQueue extends AsyncReply
|
||||
import AsyncReply from './AsyncReply.js';
|
||||
|
||||
export default class AsyncQueue extends AsyncReply
|
||||
{
|
||||
|
||||
constructor()
|
@ -26,17 +26,19 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
const ErrorType = {
|
||||
import AsyncException from './AsyncException.js';
|
||||
|
||||
export const ErrorType = {
|
||||
Management: 0,
|
||||
Exception: 1
|
||||
};
|
||||
|
||||
const ProgressType = {
|
||||
export const ProgressType = {
|
||||
Execution: 0,
|
||||
Network: 1
|
||||
};
|
||||
|
||||
class AsyncReply
|
||||
export default class AsyncReply
|
||||
{
|
||||
then(callback)
|
||||
{
|
||||
@ -113,6 +115,13 @@ class AsyncReply
|
||||
if (this.ready)
|
||||
return;
|
||||
|
||||
if (type instanceof Exception)
|
||||
{
|
||||
code = type.code;
|
||||
message = type.message;
|
||||
type = type.type;
|
||||
}
|
||||
|
||||
this.exception.raise(type, code, message);// = exception;
|
||||
|
||||
for(var i = 0; i < this.errorCallbacks.length; i++)
|
30
src/Engine/ExceptionCode.js
Normal file
30
src/Engine/ExceptionCode.js
Normal file
@ -0,0 +1,30 @@
|
||||
export default //const ExceptionCode =
|
||||
{
|
||||
HostNotReachable: 0,
|
||||
AccessDenied: 1,
|
||||
ResourceNotFound: 2,
|
||||
AttachDenied: 3,
|
||||
InvalidMethod: 4,
|
||||
InvokeDenied: 5,
|
||||
CreateDenied: 6,
|
||||
AddParentDenied: 7,
|
||||
AddChildDenied: 8,
|
||||
ViewAttributeDenied: 9,
|
||||
UpdateAttributeDenied: 10,
|
||||
StoreNotFound: 11,
|
||||
ParentNotFound: 12,
|
||||
ChildNotFound: 13,
|
||||
ResourceIsNotStore: 14,
|
||||
DeleteDenied: 15,
|
||||
DeleteFailed: 16,
|
||||
UpdateAttributeFailed: 17,
|
||||
GetAttributesFailed: 18,
|
||||
ClearAttributesFailed: 19,
|
||||
TemplateNotFound: 20,
|
||||
RenameDenied: 21,
|
||||
ClassNotFound: 22,
|
||||
MethodNotFound: 23,
|
||||
PropertyNotFound: 24,
|
||||
SetPropertyDenied: 25,
|
||||
ReadOnlyProperty: 26
|
||||
};
|
@ -26,7 +26,9 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
class IDestructible extends IEventHandler
|
||||
import IEventHandler from './IEventHandler.js';
|
||||
|
||||
export default class IDestructible extends IEventHandler
|
||||
{
|
||||
destroy()
|
||||
{
|
@ -25,7 +25,7 @@
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
class IEventHandler
|
||||
export default class IEventHandler
|
||||
{
|
||||
_register(event)
|
||||
{
|
@ -26,7 +26,23 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
class DistributedConnection extends IStore {
|
||||
import IStore from '../../Resource/IStore.js';
|
||||
import Session from '../../Security/Authority/Session.js';
|
||||
import {Authentication, AuthenticationType} from '../../Security/Authority/Authentication.js';
|
||||
import IIPPacket from '../../Net/Packets/IIPPacket.js';
|
||||
import IIPAuthPacket from '../../Net/Packets/IIPAuthPacket.js';
|
||||
import SHA256 from '../../Security/Integrity/SHA256.js';
|
||||
import {BL, DC} from '../../Data/DataConverter.js';
|
||||
import SendList from '../SendList.js';
|
||||
|
||||
import AsyncReply from '../../Engine/AsyncReply.js';
|
||||
import Codec from '../../Data/Codec.js';
|
||||
import NetworkBuffer from '../Sockets/NetworkBuffer.js';
|
||||
import KeyList from '../../Data/KeyList.js';
|
||||
import AsyncQueue from '../../Engine/AsyncQueue.js';
|
||||
import Warehouse from '../../Resource/Warehouse.js';
|
||||
|
||||
export default class DistributedConnection extends IStore {
|
||||
|
||||
send(data) {
|
||||
//console.log("Send", data.length);
|
||||
@ -46,7 +62,7 @@ class DistributedConnection extends IStore {
|
||||
return rt;
|
||||
}
|
||||
|
||||
constructor(url, domain, username, password, checkInterval = 30, connectionTimeout = 600, revivingTime = 120) {
|
||||
constructor() {
|
||||
|
||||
super();
|
||||
|
||||
@ -56,31 +72,12 @@ class DistributedConnection extends IStore {
|
||||
//this.domain = domain;
|
||||
//this.localUsername = username;
|
||||
|
||||
this._register("ready");
|
||||
this._register("error");
|
||||
//this._register("ready");
|
||||
//this._register("error");
|
||||
this._register("close");
|
||||
|
||||
this.session = new Session(new Authentication(AuthenticationType.Client), new Authentication(AuthenticationType.Host));
|
||||
|
||||
this.session.localAuthentication.domain = domain;
|
||||
this.session.localAuthentication.username = username;
|
||||
|
||||
this.localPassword = DC.stringToBytes(password);
|
||||
|
||||
this.socket = new WebSocket(url, "iip");
|
||||
this.socket.binaryType = "arraybuffer";
|
||||
this.socket.connection = this;
|
||||
this.socket.networkBuffer = new NetworkBuffer();
|
||||
|
||||
this.debug = false;
|
||||
this.totalReceived = 0;
|
||||
this.totalSent = 0;
|
||||
|
||||
this.checkInterval = checkInterval * 1000; // check every 30 seconds
|
||||
this.connectionTimeout = connectionTimeout * 1000; // 10 minutes (4 pings failed)
|
||||
this.revivingTime = revivingTime * 1000; // 2 minutes
|
||||
this.lastAction = Date.now();
|
||||
|
||||
this.packet = new IIPPacket();
|
||||
this.authPacket = new IIPAuthPacket();
|
||||
|
||||
@ -107,6 +104,54 @@ class DistributedConnection extends IStore {
|
||||
//window.crypto.getRandomValues(this.localNonce);
|
||||
|
||||
// declare (Credentials -> No Auth, No Enctypt)
|
||||
//this.socket.onerror = function(event)
|
||||
//{
|
||||
// self.close(event);
|
||||
//};
|
||||
}
|
||||
|
||||
|
||||
open(settings = {})
|
||||
{
|
||||
|
||||
var { domain = null,
|
||||
secure = false,
|
||||
username = "guest",
|
||||
password = "",
|
||||
checkInterval = 30,
|
||||
connectionTimeout = 600,
|
||||
revivingTime = 120,
|
||||
debug = false} = settings;
|
||||
|
||||
this.openReply = new AsyncReply();
|
||||
|
||||
var hostname = this.instance.name.split("://", 2)[1].split("/", 2)[0];
|
||||
|
||||
// assign domain from hostname if not provided
|
||||
domain = domain ? domain : hostname.split(":")[0];
|
||||
|
||||
this.session.localAuthentication.domain = domain;
|
||||
this.session.localAuthentication.username = username;
|
||||
|
||||
this.localPassword = DC.stringToBytes(password);
|
||||
|
||||
var url = `ws${secure ? 's' : ''}://${hostname}`;
|
||||
|
||||
|
||||
this.debug = debug;
|
||||
this.totalReceived = 0;
|
||||
this.totalSent = 0;
|
||||
|
||||
this.checkInterval = checkInterval * 1000; // check every 30 seconds
|
||||
this.connectionTimeout = connectionTimeout * 1000; // 10 minutes (4 pings failed)
|
||||
this.revivingTime = revivingTime * 1000; // 2 minutes
|
||||
this.lastAction = Date.now();
|
||||
|
||||
this.socket = new WebSocket(url, "iip");
|
||||
this.socket.binaryType = "arraybuffer";
|
||||
this.socket.connection = this;
|
||||
this.socket.networkBuffer = new NetworkBuffer();
|
||||
|
||||
var un = DC.stringToBytes(username);
|
||||
var dmn = DC.stringToBytes(domain);
|
||||
var self = this;
|
||||
@ -133,16 +178,15 @@ class DistributedConnection extends IStore {
|
||||
|
||||
this.socket.onclose = function(event)
|
||||
{
|
||||
if (this.openReply)
|
||||
this.openReply.triggerError();
|
||||
|
||||
self.close(event);
|
||||
};
|
||||
|
||||
//this.socket.onerror = function(event)
|
||||
//{
|
||||
// self.close(event);
|
||||
//};
|
||||
return this.openReply;
|
||||
}
|
||||
|
||||
|
||||
processPacket(msg, offset, ends, data)
|
||||
{
|
||||
|
||||
@ -428,7 +472,10 @@ class DistributedConnection extends IStore {
|
||||
|
||||
this.sendParams().addUint8(0x28).addUint8Array(this.session.id).done();
|
||||
this.ready = true;
|
||||
this._emit("ready", this);
|
||||
|
||||
this.openReply.trigger(this);
|
||||
|
||||
//this._emit("ready", this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -473,12 +520,16 @@ class DistributedConnection extends IStore {
|
||||
else if (authPacket.action == IIPAuthPacketAction.ConnectionEstablished) {
|
||||
this.session.id = authPacket.sessionId;
|
||||
this.ready = true;
|
||||
this._emit("ready", this);
|
||||
this.openReply.trigger(this);
|
||||
|
||||
//this._emit("ready", this);
|
||||
}
|
||||
}
|
||||
else if (authPacket.command == IIPAuthPacketCommand.Error)
|
||||
{
|
||||
this._emit("error", this, authPacket.errorCode, authPacket.errorMessage);
|
||||
this.openReply.triggerError(1, authPacket.errorCode, authPacket.errorMessage);
|
||||
|
||||
//this._emit("error", this, authPacket.errorCode, authPacket.errorMessage);
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
@ -502,8 +553,6 @@ class DistributedConnection extends IStore {
|
||||
while (offset < ends) {
|
||||
offset = this.processPacket(msg, offset, ends, data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
close(event)
|
||||
@ -1071,8 +1120,21 @@ class DistributedConnection extends IStore {
|
||||
|
||||
var rt = fi.apply(r, args);
|
||||
|
||||
function* itt() {
|
||||
|
||||
};
|
||||
|
||||
if (rt instanceof AsyncReply) {
|
||||
// Is iterator ?
|
||||
if (rt[Symbol.iterator] instanceof Function)
|
||||
{
|
||||
for (let v of rt)
|
||||
self.sendChunk(callback, v);
|
||||
|
||||
self.sendReply(IIPPacket.IIPPacketAction.InvokeFunctionArrayArguments, callback)
|
||||
.addUint8(DataType.Void)
|
||||
.done();
|
||||
}
|
||||
else if (rt instanceof AsyncReply) {
|
||||
rt.then(function (res) {
|
||||
self.sendReply(IIPPacketAction.InvokeFunctionArrayArguments, callback)
|
||||
.addUint8Array(Codec.compose(res, self))
|
||||
@ -1151,8 +1213,17 @@ class DistributedConnection extends IStore {
|
||||
|
||||
var rt = fi.apply(r, args);
|
||||
|
||||
// Is iterator ?
|
||||
if (rt[Symbol.iterator] instanceof Function)
|
||||
{
|
||||
for (let v of rt)
|
||||
self.sendChunk(callback, v);
|
||||
|
||||
if (rt instanceof AsyncReply) {
|
||||
self.sendReply(IIPPacket.IIPPacketAction.InvokeFunctionNamedArguments, callback)
|
||||
.addUint8(DataType.Void)
|
||||
.done();
|
||||
}
|
||||
else if (rt instanceof AsyncReply) {
|
||||
rt.then(function (res) {
|
||||
self.sendReply(IIPPacketAction.InvokeFunctionNamedArguments, callback)
|
||||
.addUint8Array(Codec.compose(res, self))
|
@ -26,7 +26,7 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
class DistributedPropertyContext
|
||||
export default class DistributedPropertyContext
|
||||
{
|
||||
constructor(p1, p2)
|
||||
{
|
@ -26,7 +26,11 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
class DistributedResource extends IResource
|
||||
import IResource from '../../Resource/IResource.js';
|
||||
import AsyncReply from '../../Engine/AsyncReply.js';
|
||||
import Codec from '../../Data/Codec.js';
|
||||
|
||||
export default class DistributedResource extends IResource
|
||||
{
|
||||
destroy()
|
||||
{
|
@ -26,18 +26,17 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
const DistributedResourceQueueItemType =
|
||||
export const DistributedResourceQueueItemType =
|
||||
{
|
||||
Propery: 0,
|
||||
Event: 1
|
||||
};
|
||||
|
||||
class DistributedResourceQueueItem {
|
||||
export default class DistributedResourceQueueItem {
|
||||
constructor(resource, type, value, index) {
|
||||
this.resource = resource;
|
||||
this.index = index;
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -26,7 +26,8 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
const IIPAuthPacketCommand =
|
||||
|
||||
export const IIPAuthPacketCommand =
|
||||
{
|
||||
Action: 0,
|
||||
Declare: 1,
|
||||
@ -34,7 +35,7 @@ const IIPAuthPacketCommand =
|
||||
Error: 3
|
||||
};
|
||||
|
||||
const IIPAuthPacketAction =
|
||||
export const IIPAuthPacketAction =
|
||||
{
|
||||
// Authenticate
|
||||
AuthenticateHash: 0,
|
||||
@ -44,7 +45,7 @@ const IIPAuthPacketAction =
|
||||
};
|
||||
|
||||
|
||||
const IIPAuthPacketMethod =
|
||||
export const IIPAuthPacketMethod =
|
||||
{
|
||||
None: 0,
|
||||
Certificate: 1,
|
||||
@ -52,7 +53,7 @@ const IIPAuthPacketMethod =
|
||||
Token: 3
|
||||
};
|
||||
|
||||
class IIPAuthPacket
|
||||
export default class IIPAuthPacket
|
||||
{
|
||||
constructor()
|
||||
{
|
@ -26,7 +26,7 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
const IIPPacketCommand =
|
||||
export const IIPPacketCommand =
|
||||
{
|
||||
Event: 0,
|
||||
Request: 1,
|
||||
@ -34,7 +34,7 @@ const IIPPacketCommand =
|
||||
Report: 3
|
||||
};
|
||||
|
||||
const IIPPacketReport =
|
||||
export const IIPPacketReport =
|
||||
{
|
||||
ManagementError: 0,
|
||||
ExecutionError: 1,
|
||||
@ -42,7 +42,7 @@ const IIPPacketReport =
|
||||
ChunkStream: 0x9
|
||||
};
|
||||
|
||||
const IIPPacketEvent =
|
||||
export const IIPPacketEvent =
|
||||
{
|
||||
// Event Manage
|
||||
ResourceReassigned : 0,
|
||||
@ -60,7 +60,7 @@ const IIPPacketEvent =
|
||||
|
||||
};
|
||||
|
||||
const IIPPacketAction =
|
||||
export const IIPPacketAction =
|
||||
{
|
||||
// Request Manage
|
||||
AttachResource: 0,
|
||||
@ -98,7 +98,7 @@ const IIPPacketAction =
|
||||
};
|
||||
|
||||
|
||||
class IIPPacket
|
||||
export default class IIPPacket
|
||||
{
|
||||
constructor()
|
||||
{
|
@ -26,7 +26,9 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
class SendList extends BinaryList
|
||||
import BinaryList from '../Data/BinaryList.js';
|
||||
|
||||
export default class SendList extends BinaryList
|
||||
{
|
||||
constructor(connection, doneReply)
|
||||
{
|
@ -26,7 +26,9 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
class NetworkBuffer {
|
||||
import DC from '../../Data/DataConverter.js';
|
||||
|
||||
export default class NetworkBuffer {
|
||||
constructor() {
|
||||
this.neededDataLength = 0;
|
||||
this.data = new DC(0);
|
@ -26,7 +26,7 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
class CustomResourceEvent
|
||||
export default class CustomResourceEvent
|
||||
{
|
||||
constructor(issuer, receivers, params)
|
||||
{
|
@ -26,7 +26,9 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
const ResourceTrigger =
|
||||
import IDestructible from '../Engine/IDestructible.js';
|
||||
|
||||
export const ResourceTrigger =
|
||||
{
|
||||
Loaded : 0,
|
||||
Initialize: 1,
|
||||
@ -37,7 +39,7 @@ const ResourceTrigger =
|
||||
SystemReload: 6
|
||||
};
|
||||
|
||||
class IResource extends IDestructible
|
||||
export default class IResource extends IDestructible
|
||||
{
|
||||
trigger(trigger)
|
||||
{
|
@ -26,7 +26,9 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
class IStore extends IResource {
|
||||
import IResource from './IResource.js';
|
||||
|
||||
export default class IStore extends IResource {
|
||||
get(path) {
|
||||
|
||||
}
|
@ -26,7 +26,17 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
class Instance extends IEventHandler
|
||||
import IEventHandler from '../Engine/IEventHandler.js';
|
||||
import IPermissionsManager from '../Security/Permissions/IPermissionsManager.js';
|
||||
import StructureArray from '../Data/StructureArray.js';
|
||||
import AutoList from '../Data/AutoList.js';
|
||||
import KeyList from '../Data/KeyList.js';
|
||||
import Structure from '../Data/Structure.js';
|
||||
import PropertyValue from '../Data/PropertyValue.js';
|
||||
import CustomResourceEvent from './CustomResourceEvent.js';
|
||||
import Warehouse from './Warehouse.js';
|
||||
|
||||
export default class Instance extends IEventHandler
|
||||
{
|
||||
|
||||
getAge(index)
|
@ -26,7 +26,10 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
class EventTemplate extends MemberTemplate
|
||||
import {DC, BL} from '../../Data/DataConverter.js';
|
||||
import MemberTemplate from './MemberTemplate.js';
|
||||
|
||||
export default class EventTemplate extends MemberTemplate
|
||||
{
|
||||
|
||||
constructor()
|
||||
@ -37,12 +40,12 @@ class EventTemplate extends MemberTemplate
|
||||
|
||||
compose()
|
||||
{
|
||||
var rt = new BinaryList();
|
||||
var rt = BL();
|
||||
|
||||
var name = super.compose();
|
||||
if (this.expansion != null) {
|
||||
var exp = DC.stringToBytes(this.expansion);
|
||||
return rt.addUint8(0x50).addUint32(exp.length).addUint8Array(exp).addUint8(name.length).addUint8Array(name).toArray();
|
||||
return rt.addUint8(0x50).addUint8(name.length).addUint8Array(name).addUint32(exp.length).addUint8Array(exp).toArray();
|
||||
}
|
||||
else
|
||||
return rt.addUint8(0x40).addUint32(name.length).addUint8Array(name).toArray();
|
@ -26,23 +26,25 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
class FunctionTemplate extends MemberTemplate {
|
||||
import {DC, BL} from '../../Data/DataConverter.js';
|
||||
import MemberTemplate from './MemberTemplate.js';
|
||||
|
||||
export default class FunctionTemplate extends MemberTemplate {
|
||||
compose() {
|
||||
var name = super.compose();
|
||||
var rt = new BinaryList();
|
||||
var rt = BL();
|
||||
|
||||
if (this.expansion != null) {
|
||||
var exp = DC.stringToBytes(this.expansion);
|
||||
|
||||
return rt.addUint8(0x10 | (this.isVoid ? 0x8 : 0x0))
|
||||
.addUint32(exp.length).addUint8Array(exp)
|
||||
.addUint8(name.length).addUint8Array(name).toArray();
|
||||
.addUint8(name.length).addUint8Array(name)
|
||||
.addUint32(exp.length).addUint8Array(exp).toArray();
|
||||
}
|
||||
else
|
||||
return rt.addUint8(this.isVoid ? 0x8 : 0x0).addUint8(name.length).addUint8Array(name).toArray();
|
||||
}
|
||||
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.type = MemberType.Function;
|
@ -26,13 +26,16 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
const MemberType = {
|
||||
import DC from '../../Data/DataConverter.js';
|
||||
|
||||
|
||||
export const MemberType = {
|
||||
Function: 0,
|
||||
Property: 1,
|
||||
Event: 2
|
||||
};
|
||||
|
||||
class MemberTemplate {
|
||||
export default class MemberTemplate {
|
||||
compose() {
|
||||
return DC.stringToBytes(this.name);
|
||||
}
|
@ -26,13 +26,16 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
const PropertyPermission = {
|
||||
import {DC, BL} from '../../Data/DataConverter.js';
|
||||
import MemberTemplate from './MemberTemplate.js';
|
||||
|
||||
export const PropertyPermission = {
|
||||
Read: 1,
|
||||
Write: 2,
|
||||
ReadWrite: 3
|
||||
};
|
||||
|
||||
class PropertyTemplate extends MemberTemplate
|
||||
export default class PropertyTemplate extends MemberTemplate
|
||||
{
|
||||
|
||||
constructor()
|
||||
@ -44,7 +47,7 @@ class PropertyTemplate extends MemberTemplate
|
||||
compose()
|
||||
{
|
||||
var name = super.compose();
|
||||
var rt = new BinaryList();
|
||||
var rt = BL();
|
||||
var pv = (this.permission >> 1) | (this.recordable ? 1 : 0);
|
||||
|
||||
if (this.writeExpansion != null && this.readExpansion != null)
|
||||
@ -52,34 +55,38 @@ class PropertyTemplate extends MemberTemplate
|
||||
var rexp = DC.stringToBytes(this.readExpansion);
|
||||
var wexp = DC.stringToBytes(this.writeExpansion);
|
||||
return rt.addUint8(0x38 | pv)
|
||||
.addUint8(name.length)
|
||||
.addUint8Array(name)
|
||||
.addUint32(wexp.length)
|
||||
.addUint8Array(wexp)
|
||||
.addUint32(rexp.length)
|
||||
.addUint8Array(rexp)
|
||||
.addUint8(name.length)
|
||||
.addUint8Array(name).toArray();
|
||||
.toArray();
|
||||
}
|
||||
else if (this.writeExpansion != null)
|
||||
{
|
||||
var wexp = DC.stringToBytes(this.writeExpansion);
|
||||
return rt.addUint8(0x30 | pv)
|
||||
.addUint8(name.length)
|
||||
.addUint8Array(name)
|
||||
.addUint32(wexp.length)
|
||||
.addUint8Array(wexp)
|
||||
.addUint8(name.length)
|
||||
.addUint8Array(name).toArray();
|
||||
.toArray();
|
||||
}
|
||||
else if (this.readExpansion != null)
|
||||
{
|
||||
var rexp = DC.stringToBytes(this.readExpansion);
|
||||
return rt.addUint8(0x28 | pv)
|
||||
.addUint8(name.length)
|
||||
.addUint8Array(name)
|
||||
.addUint32(rexp.length)
|
||||
.addUint8Array(rexp)
|
||||
.addUint8(name.length)
|
||||
.addUint8Array(name).toArray();
|
||||
.toArray();
|
||||
}
|
||||
else
|
||||
return rt.addUint8(0x20 | pv)
|
||||
.addUint32(name.length)
|
||||
.addUint8Array(name).toArray();
|
||||
.addUint8Array(name)
|
||||
.toArray();
|
||||
}
|
||||
}
|
@ -20,9 +20,15 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
"use strict";
|
||||
|
||||
class ResourceTemplate {
|
||||
import FunctionTemplate from './FunctionTemplate.js';
|
||||
import PropertyTemplate from './PropertyTemplate.js';
|
||||
import EventTemplate from './EventTemplate.js';
|
||||
import SHA256 from '../../Security/Integrity/SHA256.js';
|
||||
import {DC, BL} from '../../Data/DataConverter.js';
|
||||
|
||||
export default class ResourceTemplate {
|
||||
|
||||
getEventTemplateByName(eventName) {
|
||||
for (var i = 0; i < this.events.length; i++)
|
||||
@ -141,7 +147,7 @@ class ResourceTemplate {
|
||||
this.members.push(this.properties[i]);
|
||||
|
||||
// bake it binarily
|
||||
var b = new BinaryList();
|
||||
var b = BL();
|
||||
var cls = DC.stringToBytes(this.className);
|
||||
b.addUint8Array(this.classId.value)
|
||||
.addUint8(cls.length).addUint8Array(cls).addUint32(template.version).addUint16(this.members.length);
|
@ -26,22 +26,45 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
import AsyncReply from '../Engine/AsyncReply.js';
|
||||
import ResourceTemplate from '../Resource/Template/ResourceTemplate.js';
|
||||
import IEventHandler from '../Engine/IEventHandler.js';
|
||||
import AutoList from '../Data/AutoList.js';
|
||||
import KeyList from '../Data/KeyList.js';
|
||||
import DistributedConnection from '../Net/IIP/DistributedConnection.js';
|
||||
import MemoryStore from '../Stores/MemoryStore.js';
|
||||
import Instance from '../Resource/Instance.js';
|
||||
import IStore from './IStore.js';
|
||||
|
||||
class Warehouse
|
||||
|
||||
export class WH extends IEventHandler
|
||||
{
|
||||
static new(type, name, store = null, parent = null, manager = null)
|
||||
constructor()
|
||||
{
|
||||
var res = type();
|
||||
Warehouse.put(res, name, store, parent, null, 0, manager);
|
||||
super();
|
||||
|
||||
this.stores = new AutoList();
|
||||
this.resources = new KeyList();
|
||||
this.resourceCounter = 0;
|
||||
this.templates = new KeyList();
|
||||
this.protocols = new KeyList();
|
||||
this._register("connected");
|
||||
this._register("disconnected");
|
||||
}
|
||||
|
||||
new(type, name, store = null, parent = null, manager = null)
|
||||
{
|
||||
var res = new type();
|
||||
this.put(res, name, store, parent, null, 0, manager);
|
||||
return res;
|
||||
}
|
||||
|
||||
static get(id)
|
||||
get(id, settings)
|
||||
{
|
||||
if (Number.isInteger(id))
|
||||
{
|
||||
//if (Warehouse.resources.contains(id))
|
||||
return new AsyncReply(Warehouse.resources.item(id));
|
||||
return new AsyncReply(this.resources.item(id));
|
||||
//else
|
||||
// return null;
|
||||
}
|
||||
@ -78,29 +101,66 @@ class Warehouse
|
||||
}
|
||||
}
|
||||
|
||||
// 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 = this.new(handler, url[0] + "://" + hostname);
|
||||
store.open(settings).then(x=>{
|
||||
if (success)
|
||||
{
|
||||
if (pathname.length > 0 && pathname[1] != "")
|
||||
store.get(pathname[1]).then(r=>{
|
||||
rt.trigger(r);
|
||||
}).error(e => rt.triggerError(e));
|
||||
else
|
||||
rt.trigger(store);
|
||||
}
|
||||
else
|
||||
{
|
||||
self.remove(store);
|
||||
}
|
||||
}).error(e => {
|
||||
rt.triggerError(e);
|
||||
self.remove(store);
|
||||
});
|
||||
}
|
||||
|
||||
return rt;
|
||||
}
|
||||
|
||||
return new AsyncReply(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static remove(resource)
|
||||
remove(resource)
|
||||
{
|
||||
|
||||
if (Warehouse.resources.contains(resource.instance.id))
|
||||
Warehouse.resources.remove(resource.instance.id);
|
||||
if (this.resources.contains(resource.instance.id))
|
||||
this.resources.remove(resource.instance.id);
|
||||
else
|
||||
return false;
|
||||
|
||||
if (resource instanceof IStore)
|
||||
{
|
||||
Warehouse.stores.remove(resource);
|
||||
this.stores.remove(resource);
|
||||
|
||||
// remove all objects associated with the store
|
||||
var toBeRemoved = null;
|
||||
|
||||
for (var i = 0; i < Warehouse.resources.length; i++)
|
||||
for (var i = 0; i < this.resources.length; i++)
|
||||
{
|
||||
var o = Warehouse.resources.at(i);
|
||||
var o = this.resources.at(i);
|
||||
if (o.instance.store == resource)
|
||||
{
|
||||
if (toBeRemoved == null)
|
||||
@ -111,7 +171,9 @@ class Warehouse
|
||||
|
||||
if (toBeRemoved != null)
|
||||
for(var i = 0; i < toBeRemoved.length; i++)
|
||||
Warehouse.remove(toBeRemoved[i]);
|
||||
this.remove(toBeRemoved[i]);
|
||||
|
||||
this._emit("disconnected", resource);
|
||||
}
|
||||
|
||||
if (resource.instance.store != null)
|
||||
@ -121,8 +183,8 @@ class Warehouse
|
||||
return true;
|
||||
}
|
||||
|
||||
static put(resource, name, store, parent, customTemplate = null, age = 0, manager = null){
|
||||
resource.instance = new Instance(Warehouse.resourceCounter++, name, resource, store, customTemplate, age);
|
||||
put(resource, name, store, parent, customTemplate = null, age = 0, manager = null){
|
||||
resource.instance = new Instance(this.resourceCounter++, name, resource, store, customTemplate, age);
|
||||
//resource.instance.children.on("add", Warehouse._onChildrenAdd).on("remove", Warehouse._onChildrenRemove);
|
||||
//resource.instance.parents.on("add", Warehouse._onParentsAdd).on("remove", Warehouse._onParentsRemove);
|
||||
|
||||
@ -140,71 +202,74 @@ class Warehouse
|
||||
}
|
||||
|
||||
if (resource instanceof IStore)
|
||||
Warehouse.stores.add(resource);
|
||||
{
|
||||
this.stores.add(resource);
|
||||
this._emit("connected", resource);
|
||||
}
|
||||
else
|
||||
store.put(resource);
|
||||
|
||||
Warehouse.resources.add(resource.instance.id, resource);
|
||||
this.resources.add(resource.instance.id, resource);
|
||||
}
|
||||
|
||||
static _onParentsRemove(value)
|
||||
_onParentsRemove(value)
|
||||
{
|
||||
if (value.instance.children.contains(value))
|
||||
value.instance.children.remove(value);
|
||||
}
|
||||
|
||||
static _onParentsAdd(value)
|
||||
_onParentsAdd(value)
|
||||
{
|
||||
if (!value.instance.children.contains(value))
|
||||
value.instance.children.add(value);
|
||||
}
|
||||
|
||||
static _onChildrenRemove(value)
|
||||
_onChildrenRemove(value)
|
||||
{
|
||||
if (value.instance.parents.contains(value))
|
||||
value.instance.parents.remove(value);
|
||||
}
|
||||
|
||||
static _onChildrenAdd(value)
|
||||
_onChildrenAdd(value)
|
||||
{
|
||||
if (!value.instance.parents.contains(value))
|
||||
value.instance.parents.add(value);
|
||||
}
|
||||
|
||||
static putTemplate(template)
|
||||
putTemplate(template)
|
||||
{
|
||||
Warehouse.templates.add(template.classId.valueOf(), template);
|
||||
this.templates.add(template.classId.valueOf(), template);
|
||||
}
|
||||
|
||||
static getTemplateByType(type)
|
||||
getTemplateByType(type)
|
||||
{
|
||||
// loaded ?
|
||||
for (var i = 0; i < Warehouse.templates.length; i++)
|
||||
if (Warehouse.templates.at(i).className == typeof(type))
|
||||
return Warehouse.templates.at(i);
|
||||
for (var i = 0; i < this.templates.length; i++)
|
||||
if (this.templates.at(i).className == typeof(type))
|
||||
return this.templates.at(i);
|
||||
|
||||
var template = new ResourceTemplate(type);
|
||||
Warehouse.templates.add(template.classId.valueOf(), template);
|
||||
this.templates.add(template.classId.valueOf(), template);
|
||||
|
||||
return template;
|
||||
}
|
||||
|
||||
static getTemplateByClassId(classId)
|
||||
getTemplateByClassId(classId)
|
||||
{
|
||||
var template = Warehouse.templates.item(classId);
|
||||
var template = this.templates.item(classId);
|
||||
return new AsyncReply(template);
|
||||
}
|
||||
|
||||
static getTemplateByClassName(className)
|
||||
getTemplateByClassName(className)
|
||||
{
|
||||
for(var i = 0; i < Warehouse.templates.length; i++)
|
||||
if (Warehouse.templates.at(i).className == className)
|
||||
return new AsyncReply(Warehouse.templates.at(i));
|
||||
for(var i = 0; i < this.templates.length; i++)
|
||||
if (this.templates.at(i).className == className)
|
||||
return new AsyncReply(this.templates.at(i));
|
||||
|
||||
return new AsyncReply(null);
|
||||
}
|
||||
|
||||
static _qureyIn(path, index, resources)
|
||||
_qureyIn(path, index, resources)
|
||||
{
|
||||
var rt = [];
|
||||
|
||||
@ -221,20 +286,22 @@ class Warehouse
|
||||
else
|
||||
for(var i = 0; i < resources.length; i++)
|
||||
if (resources.at(i).instance.name == path[index])
|
||||
rt = rt.concat(Warehouse._qureyIn(path, index+1, resources.at(i).instance.children));
|
||||
rt = rt.concat(this._qureyIn(path, index+1, resources.at(i).instance.children));
|
||||
|
||||
return rt;
|
||||
}
|
||||
|
||||
static query(path)
|
||||
query(path)
|
||||
{
|
||||
var p = path.split('/');
|
||||
return new AsyncReply(Warehouse._qureyIn(p, 0, Warehouse.stores));
|
||||
return new AsyncReply(this._qureyIn(p, 0, this.stores));
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize
|
||||
Warehouse.stores = new AutoList();
|
||||
Warehouse.resources = new KeyList();
|
||||
Warehouse.resourceCounter = 0;
|
||||
Warehouse.templates = new KeyList();
|
||||
let Warehouse = new WH();
|
||||
|
||||
Warehouse.protocols.add("iip", DistributedConnection);
|
||||
Warehouse.protocols.add("mem", MemoryStore);
|
||||
|
||||
export default Warehouse;
|
||||
|
@ -26,14 +26,14 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
const AuthenticationType = {
|
||||
export const AuthenticationType = {
|
||||
Host: 0,
|
||||
CoHost: 1,
|
||||
Client: 2,
|
||||
Alien: 3
|
||||
};
|
||||
|
||||
class Authentication
|
||||
export default class Authentication
|
||||
{
|
||||
constructor(type)
|
||||
{
|
||||
@ -48,3 +48,5 @@
|
||||
return this.domain + "@" + this.username;
|
||||
}
|
||||
}
|
||||
|
||||
export {Authentication};
|
@ -27,7 +27,7 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
class Session
|
||||
export default class Session
|
||||
{
|
||||
constructor(localAuthentication, remoteAuthentication)
|
||||
{
|
@ -26,7 +26,9 @@
|
||||
* Ref: https://en.wikipedia.org/wiki/SHA-2
|
||||
*/
|
||||
|
||||
class SHA256
|
||||
import {DC, BL} from '../../Data/DataConverter.js';
|
||||
|
||||
export default class SHA256
|
||||
{
|
||||
|
||||
static RROT(n, d)
|
||||
@ -167,7 +169,7 @@ class SHA256
|
||||
// Produce the final hash value (big-endian):
|
||||
//digest := hash := h0 append h1 append h2 append h3 append h4 append h5 append h6 append h7
|
||||
|
||||
var results = new BinaryList();
|
||||
var results = BL();
|
||||
for(var i = 0; i < 8; i++)
|
||||
results.addUint32(hash[i]);
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
const ActionType =
|
||||
export const ActionType =
|
||||
{
|
||||
Attach: 0,
|
||||
Delete: 1,
|
||||
@ -44,13 +44,13 @@ const ActionType =
|
||||
ReceiveEvent: 13
|
||||
};
|
||||
|
||||
const Ruling = {
|
||||
export const Ruling = {
|
||||
Denied: 0,
|
||||
Allowed: 1,
|
||||
DontCare: 2,
|
||||
};
|
||||
|
||||
class IPermissionsManager
|
||||
export default class IPermissionsManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Check for permission.
|
@ -26,7 +26,9 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
class MemoryStore extends IStore
|
||||
import IStore from '../Resource/IStore.js'
|
||||
|
||||
export default class MemoryStore extends IStore
|
||||
{
|
||||
constructor()
|
||||
{
|
2
src/esiur.js
Normal file
2
src/esiur.js
Normal file
@ -0,0 +1,2 @@
|
||||
import wh from './Resource/Warehouse.js';
|
||||
export default wh;
|
@ -1,42 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../build/esiur-debug.js"></script>
|
||||
<script>
|
||||
var demo;
|
||||
|
||||
class MyStore extends IStore
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
||||
var con = new DistributedConnection("ws://localhost:5001/iip/system/iip", "localhost", "demo", "1234");
|
||||
Warehouse.put(con, "remote");
|
||||
|
||||
con.on("ready", function (d) {
|
||||
con.get("db/my").then(function(rt){
|
||||
console.log("Object received.");
|
||||
demo = rt;
|
||||
rt.on("LevelUp", function(a, b, c){
|
||||
console.log("LevelUp", a, b, c);
|
||||
});
|
||||
|
||||
rt.Add(3);
|
||||
|
||||
rt.Divide({nominator: 10, denominator: 50}).then(x=>{
|
||||
console.log(x);
|
||||
});
|
||||
|
||||
});
|
||||
}).on("error", function(sender, code, msg){
|
||||
console.log(sender, code, msg);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<!--<script src="../build/esiur-debug.js"></script>-->
|
||||
<script src='test.js' type="module"></script>
|
||||
</head>
|
||||
|
||||
<body onload="init()">
|
||||
<body onload="">
|
||||
|
||||
</body>
|
||||
</html>
|
41
test/test.js
Normal file
41
test/test.js
Normal file
@ -0,0 +1,41 @@
|
||||
var demo;
|
||||
|
||||
import IStore from '../src/Resource/IStore.js';
|
||||
import wh from '../src/Resource/Warehouse.js';
|
||||
|
||||
class MyStore extends IStore
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
wh.get("iip://localhost:5001/db/my").then(x=>{
|
||||
console.log("connected", x);
|
||||
}).error(x=>{
|
||||
console.log("error", x);
|
||||
});
|
||||
|
||||
/*
|
||||
var con = new DistributedConnection("ws://localhost:5001/iip/system/iip", "localhost", "demo", "1234");
|
||||
Warehouse.put(con, "remote");
|
||||
|
||||
con.on("ready", function (d) {
|
||||
con.get("db/my").then(function(rt){
|
||||
console.log("Object received.");
|
||||
demo = rt;
|
||||
rt.on("LevelUp", function(a, b, c){
|
||||
console.log("LevelUp", a, b, c);
|
||||
});
|
||||
|
||||
rt.Add(3);
|
||||
|
||||
rt.Divide({nominator: 10, denominator: 50}).then(x=>{
|
||||
console.log(x);
|
||||
});
|
||||
|
||||
});
|
||||
}).on("error", function(sender, code, msg){
|
||||
console.log(sender, code, msg);
|
||||
});
|
||||
*/
|
Loading…
x
Reference in New Issue
Block a user