case 'onRead':
var clients_array = [];
-
for(var i = 0; i < result.payload.length; i++) {
if (result.payload[i].key === 'client_list') {
var value = JSON.parse(result.payload[i].value);
- var client = new ClientInfo(
- converter_.toBoolean(value.isHost, false),
- converter_.toString(value.clientId, false),
- converter_.toLong(value.connectTime, false)
- );
+ var client = new ClientInfo(value);
clients_array.push(client);
}
}
console.log('Ignoring result type: [' + result_type + ']');
break;
}
-
- /*
- // TODO uncomment when implemented (or remove thid data from the protocol)
- *var clientInfo = new ClientInfo(
- result.clientInfo.isHost,
- result.clientInfo.lientId,
- result.clientInfo.connectionTime);*
- var clientInfo = null;
- */
}
});
});
}
-function ClientInfo(isHost, clientId, connectionTime) {
+function ClientInfo(data) {
validator_.isConstructorCall(this, ClientInfo);
- this.isHost = isHost;
- this.clientId = clientId;
- this.connectionTime = connectionTime;
+ Object.defineProperties(this, {
+ isHost: {
+ value: converter_.toBoolean(data.isHost),
+ writable: false,
+ enumerable: true
+ },
+ clientId: {
+ value: converter_.toString(data.clientId),
+ writable: false,
+ enumerable: true
+ },
+ connectionTime: {
+ value: converter_.toLong(data.connectTime),
+ writable: false,
+ enumerable: true
+ }
+ });
}
exports = new ConvergenceManager();