"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const light_1 = require("protobufjs/light");
const proto_1 = require("../network/proto");
const protobuf_1 = require("../protobuf");
/**
 * Status request message
 */
class StatusRequest extends light_1.Message {
    /**
     * @see README#Message classes
     */
    static register() {
        protobuf_1.registerMessage("Request", StatusRequest);
    }
}
exports.StatusRequest = StatusRequest;
/**
 * Status of a service
 */
class Status extends light_1.Message {
    constructor(props) {
        super(props);
        this.field = this.field || {};
    }
    /**
     * @see README#Message classes
     */
    static register() {
        protobuf_1.registerMessage("Status", Status);
    }
    /**
     * Get the value of a field
     * @param field The name of the field
     * @returns the value or undefined
     */
    getValue(k) {
        return this.field[k];
    }
    /**
     * Get a string representation of this status
     * @returns a string
     */
    toString() {
        return Object.keys(this.field).sort().map((k) => `${k}: ${this.field[k]}`).join("\n");
    }
}
exports.Status = Status;
/**
 * Status response message
 */
class StatusResponse extends light_1.Message {
    constructor(props) {
        super(props);
        this.status = this.status || {};
        /* Protobuf aliases */
        Object.defineProperty(this, "serveridentity", {
            get() {
                return this.serverIdentity;
            },
            set(value) {
                this.serverIdentity = value;
            },
        });
    }
    /**
     * @see README#Message classes
     */
    static register() {
        protobuf_1.registerMessage("Response", StatusResponse, Status, proto_1.ServerIdentity);
    }
    /**
     * Get the status of a service
     * @param key The name of the service
     * @returns the status
     */
    getStatus(key) {
        return this.status[key];
    }
    /**
     * Get a string representation of all the statuses
     * @returns a string
     */
    toString() {
        return Object.keys(this.status).sort().map((k) => `[${k}]\n${this.status[k].toString()}`).join("\n\n");
    }
}
exports.StatusResponse = StatusResponse;
StatusRequest.register();
StatusResponse.register();
Status.register();
