xtr-improved-frontend/src/ModelObjects/XtrServer.js

50 lines
1.1 KiB
JavaScript

const IP_INDEX = 0;
const PORT_INDEX = 1;
const AS_INDEX = 2;
const SERVER_STATUS_INDEX = 3;
/**
*
*/
export default class XtrServer {
constructor() {
this._ip = '';
this._port = '';
// autonomous system
this._as = '';
// is online ?
// http://xtr-master.xicon.eu/v3/server/list/online
this._serverStatus = '';
}
initObjectByValues (ip, port, as, serverStatus) {
this._ip = ip;
this._port = port;
this._as = as;
this._serverStatus = serverStatus;
}
initObjectByArray (element) {
this._ip = element[IP_INDEX];
this._port = element[PORT_INDEX];
this._as = element[AS_INDEX];
this._serverStatus = element[SERVER_STATUS_INDEX];
}
initObjectByJson (elemet) {
this._ip = elemet._ip;
this._port = elemet._port;
this._as = elemet._as;
this._serverStatus = elemet._serverStatus;
}
getIpPortAsString() {
return this._ip + ':' + this._port;
}
getLabelInfoString() {
return this._ip + ':' + this._port + ' ' + '(AS' + this._as + ')';
}
}