UNPKG

ftpd.js

Version:
184 lines (152 loc) 4.27 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Source: core/index.js</title> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <div id="main"> <h1 class="page-title">Source: core/index.js</h1> <section> <article> <pre class="prettyprint source linenums"><code>//Imports var path = require( "path" ), packageJSON = require( path.join( "..", "..", "package.json" ) ), Server = require( path.join( "..", "server", "index.js" ) ), util = require( "util" ), EventEmitter = require( "events" ).EventEmitter; /** * * @access public * @constructor * @param {Object} options * @since 0.6.0 */ function ftpdjs( options ) { this.options = options; this.servers = []; EventEmitter.call( this ); } util.inherits( ftpdjs, EventEmitter ); /** * * This function is used to tell ftpdjs to start setting up * * @access public * @since 0.6.0 * */ ftpdjs.prototype.setup = function () { for ( var i = 0; i &lt; this.getOptions().servers.length; i++ ) { this.setupServer( this.getOptions().servers[ i ] ); } }; /** * * This callback is used when a server have been setup * * @callback ftpdjs~didSetupServer * @param {Server} the server that finished setting up * @since 0.6.0 * */ /** * * This function is used to setup a new server from the options provided * * @access public * @param {Object} options the server options * @param {ftpdjs~didSetupServer} callback the callback to invoke when the server have finished setting up * @since 0.6.0 */ ftpdjs.prototype.setupServer = function ( options, callback ) { var server = new Server( this, options ), that = this; server.on( "state", function ( state ) { that.emit( "server:state", { state : state, server : server } ) } ); server.setup( function () { that.getServers().push( server ); if ( undefined !== callback ) { try { callback( server ); } catch ( e ) { } } } ) }; /** * @callback ftpdjs~logCallback * @param {Object} error the error if one occoured * @since 0.6.0 */ /** * * This function is used to log messages to the attached stream * * @access public * @param {string} message the message to log * @param {ftpdjs~logCallback} callback the callback to invoke when finished logging or an error occoured. Optional * @since 0.6.0 */ ftpdjs.prototype.log = function ( message, callback ) { if ( typeof(this.getOptions().logger === "function") ) { try { this.getOptions().logger.write( message + "\n", "utf8", callback ); } catch ( error ) { try { callback( error ); } catch ( e ) { } } } }; /** * * @access public * @returns {Object} the package.json for ftpd.js * @since 0.6.0 */ ftpdjs.prototype.getPackage = function () { return packageJSON; }; /** * * @access public * @returns {Object} the options Object for ftpd.js * @since 0.6.0 */ ftpdjs.prototype.getOptions = function () { return this.options; }; ftpdjs.prototype.getServers = function () { return this.servers; }; /** * * @access public * @type {ftpdjs} * @since 0.6.0 */ module.exports = ftpdjs;</code></pre> </article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="ftpdjs.html">ftpdjs</a></li><li><a href="Interface.html">Interface</a></li><li><a href="Server.html">Server</a></li><li><a href="User.html">User</a></li></ul> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0-dev</a> on Wed May 27 2015 15:03:13 GMT+0200 (CEST) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>