Skip to content

Commit

Permalink
all tests are now passing
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Bishop authored and Simon Bishop committed May 6, 2016
1 parent 532d339 commit 4385ac6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
28 changes: 18 additions & 10 deletions lib/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,16 @@ module.exports = {
if (!_this.__errorOn){
this.__happn.server.on('error', function(e) {

_this.__happn.server.lastError = e;
if (_this.__done) {
_this.__happn.server.lastError = e;
_this.__happn.log.warn('http server error', e);

// Error before listening achieved
//
// eg. EADDRINUSE
//
_this.__done(e, _this.__happn);
_this.__done = null;
}
if (_this.__done){
_this.__done(e, _this.__happn);
_this.__done == null;
}

});
_this.__errorOn = true;
Expand All @@ -74,8 +75,11 @@ module.exports = {
_this.__happn.log.info('listening at ' + _this.__info.address + ':' + _this.__info.port);
_this.__happn.log.info('happn version ' + require('../package.json').version);

_this.__done(null, _this.__happn); // <--- good, created a happn
_this.__done = null;
if (_this.__done){
_this.__done(null, _this.__happn); // <--- good, created a happn
_this.__done == null;
}

});
_this.__listeningOn = true;
}
Expand All @@ -87,6 +91,7 @@ module.exports = {
create: utils.promisify(function(config, done){
var _this = this;


if (typeof config == 'function'){
done = config;
config = {};
Expand Down Expand Up @@ -151,8 +156,11 @@ module.exports = {
happn.utils = utils;
happn.connect = app;

_this.__listening = false;
_this.__erroredOnStart = false;
_this.__listening = false;
_this.__erroredOnStart = false;
_this.__initialized = false;
_this.__listeningOn = false;
_this.__errorOn = false;

transport.createServer(config.transport, app, log, function(e, server){

Expand Down
6 changes: 4 additions & 2 deletions lib/services/pubsub/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ PubSubService.prototype.initialize = function(config, done) {
_this.primus.on('connection', _this.onConnect.bind(_this));
_this.primus.on('disconnection', _this.onDisconnect.bind(_this));

_this.primus.transform('incoming', _this.incomingTransform.bind(_this));
_this.primus.transform('outgoing', _this.outgoingTransform.bind(_this));
if (_this.happn.config.encryptPayloads){
_this.primus.transform('incoming', _this.incomingTransform.bind(_this));
_this.primus.transform('outgoing', _this.outgoingTransform.bind(_this));
}

var clientPath = path.resolve(__dirname, '../../public');

Expand Down

0 comments on commit 4385ac6

Please sign in to comment.