diff --git a/lib/net/tcp_connection.js b/lib/net/tcp_connection.js index c97ac57..a02d788 100644 --- a/lib/net/tcp_connection.js +++ b/lib/net/tcp_connection.js @@ -25,6 +25,7 @@ function TcpConnection(options) { if (logger.isDebugEnabled()) logger.debug('created with %s', this._config); } +// This method opens the connection and calls back when done TcpConnection.prototype.connect = function (callback, errorback) { var self = this; if (logger.isDebugEnabled()) logger.debug('connecting to %s', self._config); @@ -60,6 +61,7 @@ TcpConnection.prototype.connect = function (callback, errorback) { this._socket = socket; }; +// This method writes the given data and calls back when done TcpConnection.prototype.write = function (data, callback, errorback) { var self = this; var socket = this._socket; @@ -77,7 +79,6 @@ TcpConnection.prototype.write = function (data, callback, errorback) { } var message = new TcpConnection.Message({message: data}); var request = message.serialize(); -// if (logger.isDebugEnabled()) logger.debug('writing %s bytes to %s', request.length, self._config); if (logger.isDebugEnabled()) logger.debug('writing %s to %s', request.toString('hex'), self._config); socket.write(request, 'UTF8', function () { if (logger.isDebugEnabled()) logger.debug('wrote %s bytes to %s', request.length, self._config); @@ -94,6 +95,7 @@ TcpConnection.prototype.write = function (data, callback, errorback) { } }; +// This method reads the data from the connection and returns them back when done calling the callback TcpConnection.prototype.read = function (callback, errorback) { var self = this; if (logger.isDebugEnabled()) logger.debug('reading from %s', self._config); @@ -122,6 +124,7 @@ TcpConnection.prototype.read = function (callback, errorback) { } }; +// This method close the connection and calls back when done TcpConnection.prototype.close = function (callback, errorback) { var self = this; var socket = this._socket; diff --git a/lib/type_language/builder.js b/lib/type_language/builder.js index eb94d90..6efd5ac 100644 --- a/lib/type_language/builder.js +++ b/lib/type_language/builder.js @@ -23,21 +23,26 @@ var createLogger = require('../util/logger'); var logger = createLogger('type_language.Builder'); var AbstractObject = require('./index').AbstractObject; -// type register - +// type cache var types = {}; // Compile a reg exp to resolve Type declaration in TL-Schema var typeResolver = /^(\w+)(<(\w+)>)?$/; -function Builder(options) { - this.module = options.module; +// The constructor requires the following params: +// `{ +// module: 'the module name where add this new Type', +// tlSchema: 'the TypeLanguage schema that describes the Type', +// buildFunction: 'true if it's a TypeFunction, false otherwise' +// }` +function Builder(params) { + this.module = params.module; if (!this.module) { logger.warn(' Target \'module\' parameter is mandatory!'); console.trace(); return; } - this.tlSchema = options.tlSchema; + this.tlSchema = params.tlSchema; if (!this.tlSchema) { logger.warn('\'tlSchema\' parameter is mandatory!'); return; @@ -45,7 +50,7 @@ function Builder(options) { this._methods = []; // Check if is required creating a function - if (options.buildFunction) { + if (params.buildFunction) { this._type = this.buildTypeFunction(); } else { this._type = this.buildTypeConstructor(); @@ -281,7 +286,6 @@ Builder.prototype._buildReadProperty = function (propertyName, typeName) { return functionName; }; - // Register a Type constructor function registerType(type) { if(logger.isDebugEnabled()) logger.debug('Register Type \'%s\' with id [%s]', type.typeName, type.id); @@ -296,7 +300,6 @@ function retrieveType(buffer) { return type; } - // Types builder function buildTypes(schemas, types, targetModule, isMethodType) { for (var i = 0; i < schemas.length; i++) {