statusinfo.js 2.18 KB
/*
 * ADOBE CONFIDENTIAL
 * __________________
 *
 *  Copyright 2016 Adobe Systems Incorporated
 *  All Rights Reserved.
 *
 * NOTICE:  All information contained herein is, and remains
 * the property of Adobe Systems Incorporated and its suppliers,
 * if any.  The intellectual and technical concepts contained
 * herein are proprietary to Adobe Systems Incorporated and its
 * suppliers and are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Adobe Systems Incorporated.
 */

/* globals navigator */
define('screens/player/command/statusinfo', [
    'screens/player/command/command',
    'screens/player/shared/serviceadmin',
    'screens/player/firmware/statusinfo/statusinfo',
    'module'
], function(PlayerCommand, ServiceAdmin, StatusInfo, mod) {
    'use strict';

    /**
     * This command handler is able to process the following commands:
     * - "statusinfo" sends the status information of the device to the server
     *
     * @class StatusinfoCommand
     * @implements {PlayerCommand}
     */
    return _.extend({}, PlayerCommand, {

        serviceId: mod.id,

        /**
         * @function StatusinfoCommand#canHandle
         * @inheritdoc
         */
        canHandle: function(cmd) {
            return cmd === 'statusinfo';
        },

        /**
         * @function StatusinfoCommand#activate
         * @inheritdoc
         */
        activate: function() {
            return new Promise(function(resolve, reject) {
                ServiceAdmin.onServiceHighestRankedStart(StatusInfo.serviceName, function() {
                    resolve();
                });
            });
        },

        /**
         * @function StatusinfoCommand#handleCommand
         * @inheritdoc
         */
        handleCommand: function(command, payload) {
            return ServiceAdmin.getService(StatusInfo.serviceName).send();
        }

    });
});

/* istanbul ignore next */
require([
    'screens/player/command/statusinfo',
    'screens/player/shared/serviceadmin'
], function(Service, ServiceAdmin) {
    'use strict';
    ServiceAdmin.register(Service);
});