Skip to content

Commit

Permalink
Update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
enricostara committed Sep 29, 2014
1 parent 15a0ae2 commit 5382f3c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
5 changes: 4 additions & 1 deletion lib/net/tcp_connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
19 changes: 11 additions & 8 deletions lib/type_language/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,34 @@ 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;
}
this._methods = [];

// Check if is required creating a function
if (options.buildFunction) {
if (params.buildFunction) {
this._type = this.buildTypeFunction();
} else {
this._type = this.buildTypeConstructor();
Expand Down Expand Up @@ -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);
Expand All @@ -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++) {
Expand Down

0 comments on commit 5382f3c

Please sign in to comment.