mirror of
https://github.com/esiur/esiur-js.git
synced 2025-05-06 04:22:58 +00:00
ConnectionStatus
This commit is contained in:
parent
a74907526c
commit
d057f87b76
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "esiur",
|
||||
"version": "2.1.0",
|
||||
"version": "2.1.1",
|
||||
"description": "Distributed Object Framework",
|
||||
"main": "esiur.js",
|
||||
"type": "module",
|
||||
|
6
src/Net/IIP/ConnectionStatus.js
Normal file
6
src/Net/IIP/ConnectionStatus.js
Normal file
@ -0,0 +1,6 @@
|
||||
export default
|
||||
{
|
||||
Closed : 0,
|
||||
Connecting: 1,
|
||||
Connected: 2
|
||||
};
|
@ -80,6 +80,8 @@ import {TransmissionType, TransmissionTypeIdentifier} from '../../Data/Transmiss
|
||||
|
||||
import PropertyValue from '../../Data/PropertyValue.js';
|
||||
import PropertyValueArray from '../../Data/PropertyValueArray.js';
|
||||
import { UInt8 } from '../../Data/ExtendedTypes.js';
|
||||
import ConnectionStatus from './ConnectionStatus.js';
|
||||
|
||||
export default class DistributedConnection extends IStore {
|
||||
|
||||
@ -671,8 +673,11 @@ export default class DistributedConnection extends IStore {
|
||||
{
|
||||
|
||||
this.ready = true;
|
||||
this.status = ConnectionStatus.Connected;
|
||||
|
||||
this._openReply?.trigger(true);
|
||||
this._openReply = null;
|
||||
|
||||
this._emit("ready", this);
|
||||
this.server?.membership.login(this.session);
|
||||
|
||||
@ -685,8 +690,11 @@ export default class DistributedConnection extends IStore {
|
||||
else
|
||||
{
|
||||
this.ready = true;
|
||||
this.status = ConnectionStatus.Connected;
|
||||
|
||||
this._openReply?.trigger(true);
|
||||
this._openReply = null;
|
||||
|
||||
this._emit("ready", this);
|
||||
this.server?.membership.login(this.session);
|
||||
}
|
||||
@ -772,8 +780,9 @@ export default class DistributedConnection extends IStore {
|
||||
{
|
||||
this.session.id = authPacket.sessionId;
|
||||
this.ready = true;
|
||||
this._emit("ready", this);
|
||||
this.status = ConnectionStatus.Connected;
|
||||
|
||||
|
||||
// put it in the warehouse
|
||||
if (this.instance == null)
|
||||
{
|
||||
@ -1002,6 +1011,8 @@ export default class DistributedConnection extends IStore {
|
||||
if (this._openReply != null)
|
||||
throw new AsyncException(ErrorType.Exception, 0, "Connection in progress");
|
||||
|
||||
this.status = ConnectionStatus.Connecting;
|
||||
|
||||
this._openReply = new AsyncReply();
|
||||
|
||||
if (hostname != null)
|
||||
@ -1131,6 +1142,8 @@ export default class DistributedConnection extends IStore {
|
||||
{
|
||||
// clean up
|
||||
this.ready = false;
|
||||
this.status = ConnectionStatus.Closed;
|
||||
|
||||
this.readyToEstablish = false;
|
||||
|
||||
clearTimeout(this._keepAliveTimer);
|
||||
@ -3166,4 +3179,11 @@ export default class DistributedConnection extends IStore {
|
||||
this._lastKeepAliveReceived = now;
|
||||
}
|
||||
|
||||
|
||||
static get template() {
|
||||
return {
|
||||
namespace: "Esiur",
|
||||
properties: [["status", UInt8]]
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,35 +1,37 @@
|
||||
import Warehouse from "../Resource/Warehouse.js";
|
||||
|
||||
export default class ResourceProxy
|
||||
{
|
||||
export default class ResourceProxy {
|
||||
static cache = {};
|
||||
|
||||
static getProxy(type)
|
||||
{
|
||||
var template = Warehouse.getTemplateByType(type);
|
||||
var className = type.prototype.constructor.name;
|
||||
static getProxy(type) {
|
||||
let template = Warehouse.getTemplateByType(type);
|
||||
let className = type.prototype.constructor.name;
|
||||
let classUrl = "esiur://" + template.className.replace('.', '/');
|
||||
|
||||
if (template.namespace != null) {
|
||||
className = template.namespace + "_" + className;
|
||||
}
|
||||
|
||||
if (ResourceProxy.cache[className])
|
||||
return ResourceProxy.cache[className];
|
||||
|
||||
var code = `return (class E_${className} extends b { constructor() {super();} `;
|
||||
var code = `return ( class E_${className} extends b { constructor() {super();} `;
|
||||
|
||||
// generate class
|
||||
for(var i = 0; i < template.properties.length; i++)
|
||||
{
|
||||
for (var i = 0; i < template.properties.length; i++) {
|
||||
let pt = template.properties[i];
|
||||
let desc = Object.getOwnPropertyDescriptor(type.prototype, pt.name);
|
||||
if (desc)
|
||||
{
|
||||
code += `\r\n set ${pt.name}(v) { \r\n if (this.instance) this.instance.emitModification(this.instance.template.properties[${i}], v); \r\n super.${pt.name} = v; } \r\n get ${pt.name}() { \r\n return super.${pt.name};}`;
|
||||
if (desc) {
|
||||
code += `\r\n set ${pt.name}(v) { \r\n super.${pt.name} = v; \r\n if (this.instance) this.instance.emitModification(this.instance.template.properties[${i}], v); } \r\n get ${pt.name}() { \r\n return super.${pt.name};}`;
|
||||
}
|
||||
else
|
||||
{
|
||||
code += `\r\n set ${pt.name}(v) { \r\n if (this.instance) this.instance.emitModification(this.instance.template.properties[${i}], v); \r\n this._${pt.name} = v; } \r\n get ${pt.name}() { \r\n return this._${pt.name};}`;
|
||||
else {
|
||||
code += `\r\n set ${pt.name}(v) { \r\n super._${pt.name} = v; \r\n if (this.instance) this.instance.emitModification(this.instance.template.properties[${i}], v); } \r\n get ${pt.name}() { \r\n return this._${pt.name};}`;
|
||||
}
|
||||
}
|
||||
|
||||
var func = new Function("b", code + "})");
|
||||
debugger;
|
||||
|
||||
var func = new Function("b", `//# sourceURL=${classUrl} \r\n ${code}});`);
|
||||
|
||||
var proxyType = func.call(type /* this */, type);
|
||||
|
||||
|
@ -155,9 +155,9 @@ export default class Instance extends IEventHandler
|
||||
this.modificationDates[pt.index] = now;
|
||||
|
||||
if (pt.recordable)
|
||||
this.store.record(resource, pt.name, value, this.ages[pt.index], now);
|
||||
this.store?.record(resource, pt.name, value, this.ages[pt.index], now);
|
||||
else
|
||||
this.store.modify(resource, pt.name, value, this.ages[pt.index], now);
|
||||
this.store?.modify(resource, pt.name, value, this.ages[pt.index], now);
|
||||
|
||||
let pmInfo = new PropertyModificationInfo(resource, pt, value, this.instanceAge);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user