114 lines
2.4 KiB
JavaScript
114 lines
2.4 KiB
JavaScript
/**
|
|
* R3.Server
|
|
* @param apiServer R3.API.Server
|
|
* @constructor
|
|
*/
|
|
R3.Server = function(
|
|
apiServer
|
|
) {
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiServer)) {
|
|
apiServer = {};
|
|
}
|
|
|
|
R3.API.Server.call(
|
|
this,
|
|
apiServer.id,
|
|
apiServer.name,
|
|
apiServer.protocol,
|
|
apiServer.context,
|
|
apiServer.application,
|
|
apiServer.domain,
|
|
apiServer.ip,
|
|
apiServer.preferIp,
|
|
apiServer.port,
|
|
apiServer.protocols,
|
|
apiServer.parentEntity
|
|
);
|
|
|
|
this.connected = false;
|
|
|
|
R3.Component.call(this);
|
|
};
|
|
|
|
R3.Server.prototype = Object.create(R3.Component.prototype);
|
|
R3.Server.prototype.constructor = R3.Server;
|
|
|
|
R3.Server.prototype.createInstance = function() {
|
|
|
|
this.instance = true;
|
|
|
|
R3.Component.prototype.createInstance.call(this);
|
|
};
|
|
|
|
/**
|
|
* Updates the instance with the current state
|
|
*/
|
|
R3.Server.prototype.updateInstance = function(property) {
|
|
|
|
if (property === 'protocol') {
|
|
console.log('todo: server protocol update');
|
|
}
|
|
|
|
if (property === 'context') {
|
|
console.log('todo: server context update');
|
|
}
|
|
|
|
if (property === 'application') {
|
|
console.log('todo: server application update');
|
|
}
|
|
|
|
if (property === 'domain') {
|
|
console.log('todo: server domain update');
|
|
}
|
|
|
|
if (property === 'ip') {
|
|
console.log('todo: server ip update');
|
|
}
|
|
|
|
if (property === 'preferIp') {
|
|
console.log('todo: server preferIp update');
|
|
}
|
|
|
|
if (property === 'port') {
|
|
console.log('todo: server port update');
|
|
}
|
|
|
|
if (property === 'protocols') {
|
|
console.log('todo: server protocols update');
|
|
}
|
|
|
|
R3.Component.prototype.updateInstance.call(this, property);
|
|
};
|
|
|
|
/**
|
|
* Converts a R3.Server to a new R3.API.Server
|
|
* @returns {R3.API.Server}
|
|
*/
|
|
R3.Server.prototype.toApiObject = function() {
|
|
|
|
return new R3.API.Server(
|
|
this.id,
|
|
this.name,
|
|
this.protocol,
|
|
this.context,
|
|
this.application,
|
|
this.domain,
|
|
this.ip,
|
|
this.preferIp,
|
|
this.port,
|
|
this.protocols,
|
|
R3.Utils.IdOrNull(this.parentEntity)
|
|
);
|
|
|
|
};
|
|
|
|
R3.Server.prototype.getURL = function() {
|
|
|
|
if (this.preferIp) {
|
|
return this.protocol + '://' + this.ip + ':' + this.port;
|
|
} else {
|
|
return this.protocol + '://' + this.context + '-' + this.application + '.' + this.domain + ':' + this.port
|
|
}
|
|
|
|
}; |