37 lines
1.0 KiB
JavaScript
37 lines
1.0 KiB
JavaScript
/**
|
|
* @typedef {Object} LoginResponse the response from a login request
|
|
* @property {boolean} logical login was successful or not
|
|
*/
|
|
class LoginResponse {
|
|
/**
|
|
* login was successful or not
|
|
* @return {boolean} gets the value of success
|
|
*/
|
|
get success() {
|
|
return Boolean(this._data.getInt8(0, true));
|
|
}
|
|
/**
|
|
* login was successful or not
|
|
* @param {boolean} sets the value of success
|
|
*/
|
|
set success(v) {
|
|
return this._data.setInt8(0, v ? 1 : 0, true);
|
|
}
|
|
/**
|
|
* Constructs a new LoginResponse
|
|
*
|
|
* @param {{success: boolean, }} init The arguments to construct the object.
|
|
* @param {Uint8Array} ptr The pointer to the C struct.
|
|
*/
|
|
constructor(init = {}, ptr = undefined) {
|
|
this._size = 1;
|
|
this._ptr = ptr || new Uint8Array(this._size);
|
|
this._data = new DataView(this._ptr.buffer);
|
|
|
|
for (const key of Object.keys(init)) {
|
|
this[key] = init[key];
|
|
}
|
|
}
|
|
}
|
|
|
|
export default LoginResponse |