Skip to content

Commit

Permalink
use the native connection hadlers to remove them from rooms
Browse files Browse the repository at this point in the history
  • Loading branch information
evantahler committed Jan 12, 2013
1 parent 0e4bd67 commit 5d34ce4
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 10 deletions.
7 changes: 0 additions & 7 deletions initializers/socketServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,13 +297,6 @@ var socketServer = function(api, next){
//shutdown helpers
api.socketServer.gracefulShutdown = function(next, alreadyShutdown){
if(alreadyShutdown == null){alreadyShutdown = false;}
if(alreadyShutdown == false){
for(var i in api.connections){
if(api.connections[i].type == 'socket'){ api.chatRoom.roomRemoveMember(api.connections[i]) }
}
api.socketServer.server.close();
alreadyShutdown = true;
}
var pendingConnections = 0;
for(var i in api.connections){
var connection = api.connections[i];
Expand Down
3 changes: 0 additions & 3 deletions initializers/webSocketServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ var webSocketServer = function(api, next){
}

api.webSockets._teardown = function(api, next){
for(var i in api.connections){
if(api.connections[i].type == 'webSocket'){ api.chatRoom.roomRemoveMember(api.connections[i]) }
}
api.webSockets.disconnectAll(function(){
api.webServer.server.close();
next();
Expand Down
74 changes: 74 additions & 0 deletions test/core_fileServer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
describe('Action: file', function(){
var specHelper = require('../helpers/specHelper.js').specHelper;
var apiObj = {};
var should = require("should");

before(function(done){
specHelper.prepare(0, function(api){
apiObj = specHelper.cleanAPIObject(api);
done();
})
});

it('file: response is NOT json', function(done){
specHelper.apiTest.get('/public/' + "someRandomFile", 0, {}, function(response){
should.not.exist(response.body.error);
done();
});
});

it('file: 404 pages', function(done){
specHelper.apiTest.get('/public/' + "someRandomFile", 0, {}, function(response){
response.statusCode.should.equal(404)
done();
});
});

it('file: an HTML file', function(done){
specHelper.apiTest.get('/public/' + "simple.html", 0, {}, function(response){
response.statusCode.should.equal(200);
response.body.should.equal('<h1>ActionHero</h1>\\nI am a flat file being served to you via the API from ./public/index.html<br />');
done();
});
});

it('file: ?filename should work like a path', function(done){
specHelper.apiTest.get("/public/" + "?fileName=simple.html", 0, {}, function(response){
response.statusCode.should.equal(200);
response.body.should.equal('<h1>ActionHero</h1>\\nI am a flat file being served to you via the API from ./public/index.html<br />');
done();
});
});

it('I should not see files outsite of the public dir', function(done){
specHelper.apiTest.get("/public/" + "?fileName=../config.json", 0, {}, function(response){
response.statusCode.should.equal(404);
response.body.should.equal(apiObj.configData.general.flatFileNotFoundMessage);
done();
});
});

it('file: index page should be served when requesting a path', function(done){
specHelper.apiTest.get("/public/", 0, {}, function(response){
response.statusCode.should.equal(200);
response.body.should.be.a('string');
done();
});
});

it('file: sub paths should work', function(done){
specHelper.apiTest.get("/public/" + "/logo/actionHero.png", 0, {}, function(response){
response.statusCode.should.equal(200);
done();
});
});

it('file: binary files should also work', function(done){
specHelper.apiTest.get("/public/" + "/logo/actionHero.png", 0, {}, function(response){
response.statusCode.should.equal(200);
response.body.length.should.be.within(136836, 136920);
done();
});
});

});

0 comments on commit 5d34ce4

Please sign in to comment.