mirror of
https://github.com/esiur/esiur-js.git
synced 2025-06-27 07:13:12 +00:00
Esiur 1.2.3
This commit is contained in:
@ -30,6 +30,13 @@ import DataType from './DataType.js';
|
||||
import ResourceComparisonResult from './ResourceComparisionResult.js';
|
||||
import StructureComparisonResult from './StructureComparisonResult.js';
|
||||
|
||||
import AsyncBag from '../Engine/AsyncBag.js';
|
||||
import AsyncReply from '../Engine/AsyncReply.js';
|
||||
import Structure from './Structure.js';
|
||||
import PropertyValue from './PropertyValue.js';
|
||||
import {DC, BL} from './DataConverter.js';
|
||||
import BinaryList from './BinaryList.js';
|
||||
import DistributedPropertyContext from '../Net/IIP/DistributedPropertyContext.JS';
|
||||
|
||||
export default class Codec {
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
export default //const DataType =
|
||||
export default
|
||||
{
|
||||
Void: 0x0,
|
||||
//Variant,
|
||||
@ -76,35 +76,35 @@ export default //const DataType =
|
||||
|
||||
isArray: function(type)
|
||||
{
|
||||
return ((type & 0x80) == 0x80) && (type != DataType.NotModified);
|
||||
return ((type & 0x80) == 0x80) && (type != this.NotModified);
|
||||
},
|
||||
|
||||
sizeOf: function(type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case DataType.Void:
|
||||
case DataType.NotModified:
|
||||
case this.Void:
|
||||
case this.NotModified:
|
||||
return 0;
|
||||
case DataType.Bool:
|
||||
case DataType.Int8:
|
||||
case DataType.UInt8:
|
||||
case this.Bool:
|
||||
case this.Int8:
|
||||
case this.UInt8:
|
||||
return 1;
|
||||
case DataType.Char:
|
||||
case DataType.Int16:
|
||||
case DataType.UInt16:
|
||||
case this.Char:
|
||||
case this.Int16:
|
||||
case this.UInt16:
|
||||
return 2;
|
||||
case DataType.Int32:
|
||||
case DataType.UInt32:
|
||||
case DataType.Float32:
|
||||
case DataType.Resource:
|
||||
case this.Int32:
|
||||
case this.UInt32:
|
||||
case this.Float32:
|
||||
case this.Resource:
|
||||
return 4;
|
||||
case DataType.Int64:
|
||||
case DataType.UInt64:
|
||||
case DataType.Float64:
|
||||
case DataType.DateTime:
|
||||
case this.Int64:
|
||||
case this.UInt64:
|
||||
case this.Float64:
|
||||
case this.DateTime:
|
||||
return 8;
|
||||
case DataType.DistributedResource:
|
||||
case this.DistributedResource:
|
||||
return 4;
|
||||
|
||||
default:
|
||||
|
@ -40,12 +40,14 @@ export default class AsyncException extends Error
|
||||
this.code = code;
|
||||
|
||||
if (type == 0)
|
||||
{
|
||||
for(var i in ExceptionCode)
|
||||
if (ExceptionCode[i] == code)
|
||||
{
|
||||
this.message = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
this.message = message;
|
||||
|
||||
@ -54,6 +56,6 @@ export default class AsyncException extends Error
|
||||
|
||||
toString()
|
||||
{
|
||||
return this.type + " " + this.code + " " + this.message;
|
||||
return this.type + " (" + this.code + ") : " + this.message;
|
||||
}
|
||||
}
|
@ -28,16 +28,6 @@
|
||||
|
||||
import AsyncException from './AsyncException.js';
|
||||
|
||||
export const ErrorType = {
|
||||
Management: 0,
|
||||
Exception: 1
|
||||
};
|
||||
|
||||
export const ProgressType = {
|
||||
Execution: 0,
|
||||
Network: 1
|
||||
};
|
||||
|
||||
export default class AsyncReply
|
||||
{
|
||||
then(callback)
|
||||
@ -58,11 +48,18 @@ export default class AsyncReply
|
||||
return this;
|
||||
}
|
||||
|
||||
// Alias for then()
|
||||
done(callback)
|
||||
{
|
||||
this.then(callback);
|
||||
}
|
||||
|
||||
// Alias for error()
|
||||
catch(callback)
|
||||
{
|
||||
return error(callback);
|
||||
return this.error(callback);
|
||||
}
|
||||
|
||||
|
||||
error(callback)
|
||||
{
|
||||
this.errorCallbacks.push(callback);
|
||||
@ -93,6 +90,12 @@ export default class AsyncReply
|
||||
return this;
|
||||
}
|
||||
|
||||
// Alias for chunk()
|
||||
next(callback)
|
||||
{
|
||||
this.chunk(callback);
|
||||
}
|
||||
|
||||
trigger(result)
|
||||
{
|
||||
this.result = result;
|
||||
@ -110,29 +113,23 @@ export default class AsyncReply
|
||||
}
|
||||
|
||||
|
||||
triggerError(type, code, message)//exception)
|
||||
triggerError(type, code, message)
|
||||
{
|
||||
if (this.ready)
|
||||
return;
|
||||
|
||||
if (type instanceof Exception)
|
||||
{
|
||||
code = type.code;
|
||||
message = type.message;
|
||||
type = type.type;
|
||||
}
|
||||
this.taskExpired = true;
|
||||
|
||||
this.exception.raise(type, code, message);// = exception;
|
||||
if (type instanceof AsyncException)
|
||||
this.exception.raise(type.type, type.code, type.message);
|
||||
else
|
||||
this.exception.raise(type, code, message);
|
||||
|
||||
for(var i = 0; i < this.errorCallbacks.length; i++)
|
||||
this.errorCallbacks[i](this.exception, this);
|
||||
|
||||
|
||||
if (!this.taskExpired)
|
||||
{
|
||||
this.taskExpired = true;
|
||||
if (this.errorCallbacks.length == 0)
|
||||
this.rejectTask(this.exception);
|
||||
}
|
||||
else
|
||||
for(var i = 0; i < this.errorCallbacks.length; i++)
|
||||
this.errorCallbacks[i](this.exception, this);
|
||||
}
|
||||
|
||||
triggerProgress(type, value, max)
|
||||
|
4
src/Engine/ErrorType.js
Normal file
4
src/Engine/ErrorType.js
Normal file
@ -0,0 +1,4 @@
|
||||
export default {
|
||||
Management: 0,
|
||||
Exception: 1
|
||||
};
|
4
src/Engine/ProgressType.js
Normal file
4
src/Engine/ProgressType.js
Normal file
@ -0,0 +1,4 @@
|
||||
export default {
|
||||
Execution: 0,
|
||||
Network: 1
|
||||
};
|
@ -28,9 +28,9 @@
|
||||
|
||||
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 Authentication from '../../Security/Authority/Authentication.js';
|
||||
import AuthenticationType from "../../Security/Authority/AuthenticationType.js";
|
||||
|
||||
import SHA256 from '../../Security/Integrity/SHA256.js';
|
||||
import {BL, DC} from '../../Data/DataConverter.js';
|
||||
import SendList from '../SendList.js';
|
||||
@ -42,6 +42,29 @@ import KeyList from '../../Data/KeyList.js';
|
||||
import AsyncQueue from '../../Engine/AsyncQueue.js';
|
||||
import Warehouse from '../../Resource/Warehouse.js';
|
||||
|
||||
import IIPAuthPacket from "../Packets/IIPAuthPacket.js";
|
||||
import IIPPacket from "../Packets/IIPPacket.js";
|
||||
import IIPAuthPacketAction from "../Packets/IIPAuthPacketAction.js";
|
||||
import IIPAuthPacketCommand from "../Packets/IIPAuthPacketCommand.js";
|
||||
import IIPAuthPacketMethod from "../Packets/IIPAuthPacketMethod.js";
|
||||
|
||||
import IIPPacketAction from "../Packets/IIPPacketAction.js";
|
||||
import IIPPacketCommand from "../Packets/IIPPacketCommand.js";
|
||||
import IIPPacketEvent from "../Packets/IIPPacketEvent.js";
|
||||
import IIPPacketReport from "../Packets//IIPPacketReport.js";
|
||||
|
||||
import ErrorType from "../../Engine/ErrorType.js";
|
||||
import ProgressType from "../../Engine/ProgressType.js";
|
||||
import ExceptionCode from "../../Engine/ExceptionCode.js";
|
||||
|
||||
import DistributedResource from './DistributedResource.js';
|
||||
import ResourceTemplate from '../../Resource/Template/ResourceTemplate.js';
|
||||
|
||||
import DistributedResourceQueueItem from './DistributedResourceQueueItem.js';
|
||||
import DistributedResourceQueueItemType from './DistributedResourceQueueItemType.js';
|
||||
|
||||
import DistributedPropertyContext from './DistributedPropertyContext.js';
|
||||
|
||||
export default class DistributedConnection extends IStore {
|
||||
|
||||
send(data) {
|
||||
@ -157,7 +180,7 @@ export default class DistributedConnection extends IStore {
|
||||
var self = this;
|
||||
|
||||
this.socket.onopen = function () {
|
||||
var bl = new BinaryList();
|
||||
var bl = BL();
|
||||
bl.addUint8(0x60).addUint8(dmn.length).addUint8Array(dmn).addUint8Array(self.localNonce).addUint8(un.length).addUint8Array(un);
|
||||
self.send(bl.toArray());
|
||||
};
|
||||
|
@ -29,6 +29,8 @@
|
||||
import IResource from '../../Resource/IResource.js';
|
||||
import AsyncReply from '../../Engine/AsyncReply.js';
|
||||
import Codec from '../../Data/Codec.js';
|
||||
import Structure from '../../Data/Structure.js';
|
||||
import IIPPacketAction from '../Packets//IIPPacketAction.js';
|
||||
|
||||
export default class DistributedResource extends IResource
|
||||
{
|
||||
@ -87,7 +89,7 @@ export default class DistributedResource extends IResource
|
||||
{
|
||||
var func = function () {
|
||||
|
||||
if ( arguments.length = 1
|
||||
if ( arguments.length == 1
|
||||
&& arguments[0] instanceof Object
|
||||
&& arguments[0].constructor.name == "Object")
|
||||
{
|
||||
|
@ -26,11 +26,6 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
export const DistributedResourceQueueItemType =
|
||||
{
|
||||
Propery: 0,
|
||||
Event: 1
|
||||
};
|
||||
|
||||
export default class DistributedResourceQueueItem {
|
||||
constructor(resource, type, value, index) {
|
||||
|
6
src/Net/IIP/DistributedResourceQueueItemType.js
Normal file
6
src/Net/IIP/DistributedResourceQueueItemType.js
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
export default
|
||||
{
|
||||
Propery: 0,
|
||||
Event: 1
|
||||
};
|
@ -27,31 +27,9 @@
|
||||
"use strict";
|
||||
|
||||
|
||||
export const IIPAuthPacketCommand =
|
||||
{
|
||||
Action: 0,
|
||||
Declare: 1,
|
||||
Acknowledge: 2,
|
||||
Error: 3
|
||||
};
|
||||
|
||||
export const IIPAuthPacketAction =
|
||||
{
|
||||
// Authenticate
|
||||
AuthenticateHash: 0,
|
||||
NewConnection: 0x20,
|
||||
ResumeConnection: 0x21,
|
||||
ConnectionEstablished: 0x28
|
||||
};
|
||||
|
||||
|
||||
export const IIPAuthPacketMethod =
|
||||
{
|
||||
None: 0,
|
||||
Certificate: 1,
|
||||
Credentials: 2,
|
||||
Token: 3
|
||||
};
|
||||
import IIPAuthPacketCommand from "./IIPAuthPacketCommand.js";
|
||||
import IIPAuthPacketAction from "./IIPAuthPacketAction.js";
|
||||
import IIPAuthPacketMethod from "./IIPAuthPacketMethod.js";
|
||||
|
||||
export default class IIPAuthPacket
|
||||
{
|
||||
|
8
src/Net/Packets/IIPAuthPacketAction.js
Normal file
8
src/Net/Packets/IIPAuthPacketAction.js
Normal file
@ -0,0 +1,8 @@
|
||||
export default // const IIPAuthPacketAction =
|
||||
{
|
||||
// Authenticate
|
||||
AuthenticateHash: 0,
|
||||
NewConnection: 0x20,
|
||||
ResumeConnection: 0x21,
|
||||
ConnectionEstablished: 0x28
|
||||
};
|
7
src/Net/Packets/IIPAuthPacketCommand.js
Normal file
7
src/Net/Packets/IIPAuthPacketCommand.js
Normal file
@ -0,0 +1,7 @@
|
||||
export default //const IIPAuthPacketCommand =
|
||||
{
|
||||
Action: 0,
|
||||
Declare: 1,
|
||||
Acknowledge: 2,
|
||||
Error: 3
|
||||
};
|
7
src/Net/Packets/IIPAuthPacketMethod.js
Normal file
7
src/Net/Packets/IIPAuthPacketMethod.js
Normal file
@ -0,0 +1,7 @@
|
||||
export default //const IIPAuthPacketMethod =
|
||||
{
|
||||
None: 0,
|
||||
Certificate: 1,
|
||||
Credentials: 2,
|
||||
Token: 3
|
||||
};
|
@ -26,77 +26,11 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
export const IIPPacketCommand =
|
||||
{
|
||||
Event: 0,
|
||||
Request: 1,
|
||||
Reply: 2,
|
||||
Report: 3
|
||||
};
|
||||
|
||||
export const IIPPacketReport =
|
||||
{
|
||||
ManagementError: 0,
|
||||
ExecutionError: 1,
|
||||
ProgressReport: 0x8,
|
||||
ChunkStream: 0x9
|
||||
};
|
||||
|
||||
export const IIPPacketEvent =
|
||||
{
|
||||
// Event Manage
|
||||
ResourceReassigned : 0,
|
||||
ResourceDestroyed: 1,
|
||||
ChildAdded: 2,
|
||||
ChildRemoved: 3,
|
||||
Renamed: 4,
|
||||
|
||||
// Event Invoke
|
||||
PropertyUpdated : 0x10,
|
||||
EventOccurred: 0x11,
|
||||
|
||||
// Attribute
|
||||
AttributesUpdated: 0x18
|
||||
|
||||
};
|
||||
|
||||
export const IIPPacketAction =
|
||||
{
|
||||
// Request Manage
|
||||
AttachResource: 0,
|
||||
ReattachResource: 1,
|
||||
DetachResource: 2,
|
||||
CreateResource: 3,
|
||||
DeleteResource: 4,
|
||||
AddChild: 5,
|
||||
RemoveChild: 6,
|
||||
RenameResource: 7,
|
||||
|
||||
// Request Inquire
|
||||
TemplateFromClassName: 8,
|
||||
TemplateFromClassId: 9,
|
||||
TemplateFromResourceId: 10,
|
||||
QueryLink: 11,
|
||||
ResourceHistory: 12,
|
||||
ResourceChildren: 13,
|
||||
ResourceParents: 14,
|
||||
|
||||
// Request Invoke
|
||||
InvokeFunctionArrayArguments: 16,
|
||||
GetProperty: 17,
|
||||
GetPropertyIfModified: 18,
|
||||
SetProperty: 19,
|
||||
InvokeFunctionNamedArguments: 20,
|
||||
|
||||
// Request Attribute
|
||||
GetAllAttributes: 24,
|
||||
UpdateAllAttributes: 25,
|
||||
ClearAllAttributes: 26,
|
||||
GetAttributes: 27,
|
||||
UpdateAttributes: 28,
|
||||
ClearAttributes: 29
|
||||
};
|
||||
|
||||
import IIPPacketAction from "./IIPPacketAction.js";
|
||||
import IIPPacketCommand from "./IIPPacketCommand.js";
|
||||
import IIPPacketEvent from "./IIPPacketEvent.js";
|
||||
import IIPPacketReport from "./IIPPacketReport.js";
|
||||
import DataType from '../../Data/DataType.js';
|
||||
|
||||
export default class IIPPacket
|
||||
{
|
||||
|
36
src/Net/Packets/IIPPacketAction.js
Normal file
36
src/Net/Packets/IIPPacketAction.js
Normal file
@ -0,0 +1,36 @@
|
||||
export default // const IIPPacketAction =
|
||||
{
|
||||
// Request Manage
|
||||
AttachResource: 0,
|
||||
ReattachResource: 1,
|
||||
DetachResource: 2,
|
||||
CreateResource: 3,
|
||||
DeleteResource: 4,
|
||||
AddChild: 5,
|
||||
RemoveChild: 6,
|
||||
RenameResource: 7,
|
||||
|
||||
// Request Inquire
|
||||
TemplateFromClassName: 8,
|
||||
TemplateFromClassId: 9,
|
||||
TemplateFromResourceId: 10,
|
||||
QueryLink: 11,
|
||||
ResourceHistory: 12,
|
||||
ResourceChildren: 13,
|
||||
ResourceParents: 14,
|
||||
|
||||
// Request Invoke
|
||||
InvokeFunctionArrayArguments: 16,
|
||||
GetProperty: 17,
|
||||
GetPropertyIfModified: 18,
|
||||
SetProperty: 19,
|
||||
InvokeFunctionNamedArguments: 20,
|
||||
|
||||
// Request Attribute
|
||||
GetAllAttributes: 24,
|
||||
UpdateAllAttributes: 25,
|
||||
ClearAllAttributes: 26,
|
||||
GetAttributes: 27,
|
||||
UpdateAttributes: 28,
|
||||
ClearAttributes: 29
|
||||
};
|
7
src/Net/Packets/IIPPacketCommand.js
Normal file
7
src/Net/Packets/IIPPacketCommand.js
Normal file
@ -0,0 +1,7 @@
|
||||
export default // IIPPacketCommand =
|
||||
{
|
||||
Event: 0,
|
||||
Request: 1,
|
||||
Reply: 2,
|
||||
Report: 3
|
||||
};
|
19
src/Net/Packets/IIPPacketEvent.js
Normal file
19
src/Net/Packets/IIPPacketEvent.js
Normal file
@ -0,0 +1,19 @@
|
||||
const IIPPacketEvent =
|
||||
{
|
||||
// Event Manage
|
||||
ResourceReassigned : 0,
|
||||
ResourceDestroyed: 1,
|
||||
ChildAdded: 2,
|
||||
ChildRemoved: 3,
|
||||
Renamed: 4,
|
||||
|
||||
// Event Invoke
|
||||
PropertyUpdated : 0x10,
|
||||
EventOccurred: 0x11,
|
||||
|
||||
// Attribute
|
||||
AttributesUpdated: 0x18
|
||||
|
||||
};
|
||||
|
||||
export default IIPPacketEvent;
|
9
src/Net/Packets/IIPPacketReport.js
Normal file
9
src/Net/Packets/IIPPacketReport.js
Normal file
@ -0,0 +1,9 @@
|
||||
const IIPPacketReport =
|
||||
{
|
||||
ManagementError: 0,
|
||||
ExecutionError: 1,
|
||||
ProgressReport: 0x8,
|
||||
ChunkStream: 0x9
|
||||
};
|
||||
|
||||
export default IIPPacketReport;
|
@ -28,6 +28,7 @@
|
||||
|
||||
import {DC, BL} from '../../Data/DataConverter.js';
|
||||
import MemberTemplate from './MemberTemplate.js';
|
||||
import MemberType from './MemberType.js';
|
||||
|
||||
export default class EventTemplate extends MemberTemplate
|
||||
{
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
import {DC, BL} from '../../Data/DataConverter.js';
|
||||
import MemberTemplate from './MemberTemplate.js';
|
||||
import MemberType from './MemberType.js';
|
||||
|
||||
export default class FunctionTemplate extends MemberTemplate {
|
||||
compose() {
|
||||
|
@ -28,13 +28,6 @@
|
||||
|
||||
import DC from '../../Data/DataConverter.js';
|
||||
|
||||
|
||||
export const MemberType = {
|
||||
Function: 0,
|
||||
Property: 1,
|
||||
Event: 2
|
||||
};
|
||||
|
||||
export default class MemberTemplate {
|
||||
compose() {
|
||||
return DC.stringToBytes(this.name);
|
||||
|
6
src/Resource/Template/MemberType.js
Normal file
6
src/Resource/Template/MemberType.js
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
export default {
|
||||
Function: 0,
|
||||
Property: 1,
|
||||
Event: 2
|
||||
};
|
@ -28,6 +28,7 @@
|
||||
|
||||
import {DC, BL} from '../../Data/DataConverter.js';
|
||||
import MemberTemplate from './MemberTemplate.js';
|
||||
import MemberType from './MemberType.js';
|
||||
|
||||
export const PropertyPermission = {
|
||||
Read: 1,
|
||||
|
@ -116,19 +116,13 @@ export class WH extends IEventHandler
|
||||
{
|
||||
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);
|
||||
}
|
||||
if (pathname.length > 0 && pathname[1] != "")
|
||||
store.get(pathname).then(r=>{
|
||||
rt.trigger(r);
|
||||
}).error(e => rt.triggerError(e));
|
||||
else
|
||||
{
|
||||
self.remove(store);
|
||||
}
|
||||
rt.trigger(store);
|
||||
|
||||
}).error(e => {
|
||||
rt.triggerError(e);
|
||||
self.remove(store);
|
||||
|
@ -26,14 +26,8 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
export const AuthenticationType = {
|
||||
Host: 0,
|
||||
CoHost: 1,
|
||||
Client: 2,
|
||||
Alien: 3
|
||||
};
|
||||
|
||||
export default class Authentication
|
||||
export default class Authentication
|
||||
{
|
||||
constructor(type)
|
||||
{
|
||||
@ -47,6 +41,4 @@
|
||||
{
|
||||
return this.domain + "@" + this.username;
|
||||
}
|
||||
}
|
||||
|
||||
export {Authentication};
|
||||
}
|
6
src/Security/Authority/AuthenticationType.js
Normal file
6
src/Security/Authority/AuthenticationType.js
Normal file
@ -0,0 +1,6 @@
|
||||
export default { //const AuthenticationType = {
|
||||
Host: 0,
|
||||
CoHost: 1,
|
||||
Client: 2,
|
||||
Alien: 3
|
||||
};
|
Reference in New Issue
Block a user