Skip to content

Commit

Permalink
Continuing to reorganize and flush out MVP
Browse files Browse the repository at this point in the history
Removes Routes files and merges them into controllers

(interim commit)

[airbug/airbug#89] Airbug. Airbug MVP Part I: Chat Basics
  • Loading branch information
sungchoi committed May 28, 2013
1 parent 701a628 commit f7f40a1
Show file tree
Hide file tree
Showing 28 changed files with 816 additions and 569 deletions.
396 changes: 327 additions & 69 deletions projects/airbugserver/js/src/AirBugConfiguration.js

Large diffs are not rendered by default.

20 changes: 14 additions & 6 deletions projects/airbugserver/js/src/Controllers/AlphaPagesController.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,25 @@ var Obj = bugpack.require('Obj');

var AlphaPagesController = Class.extend(Obj, {

_constructor: function(){
_constructor: function(expressRoutesManager){

this._super();

this.expressRoutesManager = expressRoutesManager;

},

home: function(req, res){
res.render('alpha', {
title: 'airbug',
production: config.production
});
configure: function(){

this.expressRoutesManager.addAll([

new ExpressRoute('get', '/alpha', function(req, res){
res.render('alpha', {
title: 'airbug',
production: config.production
});
})
]);
}
});

Expand Down
89 changes: 53 additions & 36 deletions projects/airbugserver/js/src/Controllers/RoomsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

//@Require('Class')
//@Require('Obj')
//@Require('bugflow.BugFlow')


//-------------------------------------------------------------------------------
// Common Modules
Expand All @@ -20,21 +22,34 @@ var bugpack = require('bugpack').context();
// Bugpack Modules
//-------------------------------------------------------------------------------

var BugFlow = bugpack.require('bugflow.BugFlow');
var Class = bugpack.require('Class');
var Obj = bugpack.require('Obj');


//-------------------------------------------------------------------------------
// Simplify References
//-------------------------------------------------------------------------------

var $series = BugFlow.$series;
var $task = BugFlow.$task;


//-------------------------------------------------------------------------------
// Declare Class
//-------------------------------------------------------------------------------

var RoomsController = Class.extend(Obj, {

_constructor: function(roomService){
_constructor: function(socketIoManager, roomService){

this._super();

this.roomService = roomService;
this.roomService = roomService;

this.socketIoManager = socketIoManager;

this.ioManager = null;

},

Expand All @@ -43,46 +58,48 @@ var RoomsController = Class.extend(Obj, {
// Methods
//-------------------------------------------------------------------------------

// configure: function(){
//
// },


/*
* @param {} params
**/
createRoom: function(params){
if(currentUser){
this.roomService.create(params)
}
},

/*
* @param {} params
**/
joinRoom: function(params){
if(currentUser){
var roomId = params.roomId || params.room.id;
this.roomService.addUserToRoom(currentUser, roomId);
}
},

/*
* @param {} params
**/
leaveRoom: function(params){
if(currentUser){
var roomId = params.roomId || params.room.id;
this.roomService.removeUserFromRoom(currentUser, roomId);
}
},
configure: function(callback){
var _this = this;
var callback = callback || function(){};
var ioManager = this.socketIoManager.getIoManager();
this.socketRoutesManager = new RoutesManager(ioManager);
this.socketRoutesManager.addAll([
new SocketRoute("addUserToRoom", function(params){

}),
new SocketRoute("createRoom", function(params){
var room;
if(currentUser){
_this.roomService.create(room)
}
}),
new SocketRoute("joinRoom", function(params){
if(currentUser){
var roomId = params.roomId || params.room.id;
_this.roomService.addUserToRoom(currentUser, roomId);
}
}),
new SocketRoute("leaveRoom", function(params){
if(currentUser){
_this.roomService.removeUserFromRoom(currentUser, roomId);
}
})
]);

callback();

},

//-------------------------------------------------------------------------------
// Private Methods
//-------------------------------------------------------------------------------

pre: function(){
pre: function(params, callback){
if(currentUser){
callback();
} else {

}
}
});

Expand Down
62 changes: 40 additions & 22 deletions projects/airbugserver/js/src/Controllers/UsersController.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

//@Require('Class')
//@Require('Obj')
//@Require('bugflow.BugFlow')

//-------------------------------------------------------------------------------
// Common Modules
Expand All @@ -20,48 +21,65 @@ var bugpack = require('bugpack').context();
// Bugpack Modules
//-------------------------------------------------------------------------------

var BugFlow = bugpack.require('bugflow.BugFlow');
var Class = bugpack.require('Class');
var Obj = bugpack.require('Obj');


//-------------------------------------------------------------------------------
// Simplify References
//-------------------------------------------------------------------------------

var $series = BugFlow.$series;
var $task = BugFlow.$task;


//-------------------------------------------------------------------------------
// Declare Class
//-------------------------------------------------------------------------------

var UsersController = Class.extend(Obj, {

_constructor: function(){
_constructor: function(socketIoManager, userService){

this._super();

this.socketIoManager = socketIoManager;

this.socketRoutesManager = null;

this.userService = userService;

},


//-------------------------------------------------------------------------------
// Methods
//-------------------------------------------------------------------------------

/*
* @param {}
**/
establishUser: function(params){
UserService.establishUser();
},

/*
* @param {}
**/
getCurrentUser: function(params){

},

/*
* @param {}
**/
logoutCurrentUser: function(params){

}

configure: function(callback){
var _this = this;
var callback = callback || function(){};
var ioManager = this.socketIoManager.getIoManager();
this.socketRoutesManager = new RoutesManager(ioManager);
this.socketRoutesManager.addAll([
new SocketRoute("establishUser", function(params){
var user = {
email: params.user.email,
name: params.user.name
};
_this.userService.establishUser(user);
}),
new SocketRoute("getCurrentUser", function(params){

}),
new SocketRoute("logoutCurrentUser", function(params){

})
]);

callback();
}
});


Expand Down
21 changes: 17 additions & 4 deletions projects/airbugserver/js/src/Managers/ChatMessageManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

//@Require('Class')
//@Require('Obj')
//@Require('Proxy')


//-------------------------------------------------------------------------------
Expand All @@ -23,24 +24,36 @@ var bugpack = require('bugpack').context();

var Class = bugpack.require('Class');
var Obj = bugpack.require('Obj');
var Proxy = bugpack.require('Proxy');

//-------------------------------------------------------------------------------
// Declare Class
//-------------------------------------------------------------------------------

var ChatMessageManager = Class.extend(Obj, {

_constructor: function(model){
_constructor: function(model, schema){

this._super();

this.model = model;
this.model = model;

this.schema = schema;

},

configure: function(callback){
if(!callback || typeof callback !== 'function'){
callback = function(){};
}
callback();
},

create: function(message, callback){
var newChatMessage = this.model.create(message, callback);
// RoomApi.sendMessage(newChatMessage);
if(!callback || typeof callback !== 'function'){
callback = function(){};
}
this.model.create(message, callback);
}
});

Expand Down
14 changes: 12 additions & 2 deletions projects/airbugserver/js/src/Managers/ConversationManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

//@Require('Class')
//@Require('Obj')

//@Require('Proxy')

//-------------------------------------------------------------------------------
// Common Modules
Expand All @@ -23,19 +23,29 @@ var bugpack = require('bugpack').context();

var Class = bugpack.require('Class');
var Obj = bugpack.require('Obj');
var Proxy = bugpack.require('Proxy');

//-------------------------------------------------------------------------------
// Declare Class
//-------------------------------------------------------------------------------

var ConversationManager = Class.extend(Obj, {

_constructor: function(model){
_constructor: function(model, schema){

this._super();

this.model = model;

this.schema = schema;
},


configure: function(callback){
if(!callback || typeof callback !== 'function'){
callback = function(){};
}
callback();
}
});

Expand Down
Loading

0 comments on commit f7f40a1

Please sign in to comment.