UNPKG

pinusmod

Version:

[![Build Status](https://travis-ci.org/node-pinus/pinus.svg?branch=master)](https://travis-ci.org/node-pinus/pinus)

63 lines (62 loc) 1.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ServerComponent = void 0; /** * Component for server starup. */ const server_1 = require("../server/server"); /** * Server component class * * @param {Object} app current application context */ class ServerComponent { constructor(app, opts) { this.name = '__server__'; this.server = (0, server_1.create)(app, opts); } /** * Component lifecycle callback * * @param {Function} cb * @return {Void} */ start(cb) { this.server.start(); process.nextTick(cb); } /** * Component lifecycle callback * * @param {Function} cb * @return {Void} */ afterStart(cb) { this.server.afterStart(); process.nextTick(cb); } /** * Component lifecycle function * * @param {Boolean} force whether stop the component immediately * @param {Function} cb * @return {Void} */ stop(force, cb) { this.server.stop(); process.nextTick(cb); } /** * Proxy server handle */ handle(msg, session, cb) { this.server.handle(msg, session, cb); } /** * Proxy server global handle */ globalHandle(msg, session, cb) { this.server.globalHandle(msg, session, cb); } } exports.ServerComponent = ServerComponent;