-
Notifications
You must be signed in to change notification settings - Fork 110
realtime app chatofpomelo
Pomelo is a fast, scalable game server framework for node.js. It provides the basic development framework and many related components, including libraries and tools. Pomelo is also suitable for real-time web applications; its distributed architecture makes pomelo scale better than other real-time web frameworks.
With Bearcat, developing real-time app with pomelo will be easier, faster and more maintainable.
Let's start our Bearcat in action tutorial series -- realtime app chatofpomelo
Pomelo abstracts handler that handles client request and remote that handles remote rpc calls, both of these can be wrapped into simple POJOs, and then become simple, reuseable and maintainable.
add bearcat to package.json
"bearcat": "~0.1.0"
add context.json
{
"name": "chatofpomelo-websocket-bearcat",
"beans": []
}
var contextPath = require.resolve('./context.json');
var bearcat = Bearcat.createApp([contextPath]);
bearcat.start(function() {
app.set('bearcat', bearcat);
// start app
app.start();
});
module.exports = function(app) {
var bearcat = app.get('bearcat');
return bearcat.getBean({
id: "gateHandler",
func: Handler,
args: [{
name: "app",
value: app
}]
});
};
var Handler = function(app) {
this.app = app;
};
module.exports = function(app) {
var bearcat = app.get('bearcat');
return bearcat.getBean({
id: "chatRemote",
func: ChatRemote,
args: [{
name: "app",
value: app
}]
});
};
var ChatRemote = function(app) {
this.app = app;
this.channelService = app.get('channelService');
};
node app.js
the whole repository is chatofpomelo-websocket-bearcat