Skip to content
This repository has been archived by the owner on Nov 12, 2019. It is now read-only.

Commit

Permalink
Sorting out the options ad id magik
Browse files Browse the repository at this point in the history
  • Loading branch information
theangryangel committed Apr 5, 2013
1 parent 0c7eb5f commit 3ebe049
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
9 changes: 8 additions & 1 deletion lib/protocols/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
var util = require('util'),
events = require('events'),
product = require('../product'),
_ = require('underscore'),
uuid = require('node-uuid');

var devnull = {
Expand All @@ -15,11 +16,17 @@ var client = function(options, log)
{
events.EventEmitter.call(this);

this.defaults = {
};

this.product = product;
this.decoders = [];
this.log = log || devnull;

this.id = uuid.v4();
this.options = _.defaults(options, this.defaults);

if (!this.options.id)
this.id = uuid.v4()
}

util.inherits(client, events.EventEmitter);
Expand Down
7 changes: 4 additions & 3 deletions lib/protocols/insim.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@ var util = require('util'),
var client = function(options, log)
{
var self = this;
base.call(this, options, log);

this.options = _.defaults(options, {
this.defaults = {
protocol: 'tcp',
host: '127.0.0.1',
port: 29999,
udpport: -1,
admin: '',
prefix: '',
isiflags: 0
});
};

base.call(this, options, log);

this.connections = [];

Expand Down
7 changes: 6 additions & 1 deletion lib/protocols/outgauge.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ var util = require('util'),

var client = function(options, log)
{
this.defaults = {
port: 12345,
host: null
};

base.call(this, options, log);

this.decoders = [
Expand All @@ -16,7 +21,7 @@ var client = function(options, log)
this.relay = relay;
this.insim = insim;

this.connection = new udp(null, null);
this.connection = new udp(this.options.port, this.options.host);
}

util.inherits(client, base);
Expand Down
7 changes: 6 additions & 1 deletion lib/protocols/outsim.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ var util = require('util'),

var client = function(options, log)
{
this.defaults = {
port: 12345,
host: null
};

base.call(this, options, log);

this.decoders = [
Expand All @@ -16,7 +21,7 @@ var client = function(options, log)
this.relay = relay;
this.insim = insim;

this.connection = new udp(null, null);
this.connection = new udp(this.options.port, this.options.host);
}

util.inherits(client, base);
Expand Down
7 changes: 4 additions & 3 deletions lib/protocols/relay.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ var util = require('util'),
var client = function(options, log)
{
var self = this;
base.call(this, options, log);

this.options = _.defaults(options, {
this.defaults = {
host: '',
admin: '',
spec: ''
});
};

base.call(this, options, log);

this.connection = null;

Expand Down

0 comments on commit 3ebe049

Please sign in to comment.