Skip to content

Commit

Permalink
add mqtt in bin/pomelo
Browse files Browse the repository at this point in the history
Change-Id: If9566d45393e5e9c17c6423032dc0e70351ba17f
  • Loading branch information
py8765 committed May 30, 2014
1 parent 57dcb13 commit 74510dd
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 3 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
language: node_js
node_js:
- "0.8"
- "0.10"
before_script:
- npm install -g grunt-cli
29 changes: 28 additions & 1 deletion bin/pomelo
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ function createApplicationAt(ph, type) {
// use websocket
var unlinkFiles = ['game-server/app.js.sio',
'game-server/app.js.wss',
'game-server/app.js.mqtt',
'game-server/app.js.sio.wss',
'game-server/app.js.udp',
'web-server/app.js.https',
Expand All @@ -215,6 +216,7 @@ function createApplicationAt(ph, type) {
var unlinkFiles = ['game-server/app.js',
'game-server/app.js.wss',
'game-server/app.js.udp',
'game-server/app.js.mqtt',
'game-server/app.js.sio.wss',
'web-server/app.js.https',
'web-server/public/index.html',
Expand All @@ -236,6 +238,7 @@ function createApplicationAt(ph, type) {
'game-server/app.js',
'game-server/app.js.udp',
'game-server/app.js.sio.wss',
'game-server/app.js.mqtt',
'web-server/app.js',
'web-server/public/index.html.sio',
'web-server/public/js/lib/pomeloclient.js',
Expand All @@ -256,6 +259,7 @@ function createApplicationAt(ph, type) {
'game-server/app.js',
'game-server/app.js.udp',
'game-server/app.js.wss',
'game-server/app.js.mqtt',
'web-server/app.js',
'web-server/public/index.html',
'web-server/public/js/lib/pomeloclient.js'];
Expand All @@ -277,6 +281,7 @@ function createApplicationAt(ph, type) {
var unlinkFiles = ['game-server/app.js.sio',
'game-server/app.js',
'game-server/app.js.wss',
'game-server/app.js.mqtt',
'game-server/app.js.sio.wss',
'web-server/app.js.https',
'web-server/public/index.html',
Expand All @@ -287,6 +292,27 @@ function createApplicationAt(ph, type) {
}

fs.renameSync(path.resolve(ph, 'game-server/app.js.udp'), path.resolve(ph, 'game-server/app.js'));
rmdir(path.resolve(ph, 'web-server/public/js/lib/build'));
rmdir(path.resolve(ph, 'web-server/public/js/lib/local'));
break;
case '6':
// use socket.io
var unlinkFiles = ['game-server/app.js',
'game-server/app.js.wss',
'game-server/app.js.udp',
'game-server/app.js.sio',
'game-server/app.js.sio.wss',
'web-server/app.js.https',
'web-server/public/index.html',
'web-server/public/js/lib/component.json',
'web-server/public/js/lib/pomeloclient.js.wss'];
for(var i = 0; i < unlinkFiles.length; ++i) {
fs.unlinkSync(path.resolve(ph, unlinkFiles[i]));
}

fs.renameSync(path.resolve(ph, 'game-server/app.js.mqtt'), path.resolve(ph, 'game-server/app.js'));
fs.renameSync(path.resolve(ph, 'web-server/public/index.html.sio'), path.resolve(ph, 'web-server/public/index.html'));

rmdir(path.resolve(ph, 'web-server/public/js/lib/build'));
rmdir(path.resolve(ph, 'web-server/public/js/lib/local'));
break;
Expand Down Expand Up @@ -608,7 +634,7 @@ function mkdir(path, fn) {
* @param {Function} cb
*/
function connectorType(cb) {
prompt('Please select underly connector, 1 for websocket(native socket), 2 for socket.io, 3 for wss, 4 for socket.io(wss), 5 for udp: [1] ', function(msg) {
prompt('Please select underly connector, 1 for websocket(native socket), 2 for socket.io, 3 for wss, 4 for socket.io(wss), 5 for udp, 6 for mqtt: [1]', function(msg) {
switch(msg.trim()) {
case '':
cb(1);
Expand All @@ -618,6 +644,7 @@ function connectorType(cb) {
case '3':
case '4':
case '5':
case '6':
cb(msg.trim());
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var Handler = function(app) {
};

/**
* New client entry chat server.
* New client entry.
*
* @param {Object} msg request message
* @param {Object} session current session object
Expand All @@ -17,3 +17,27 @@ var Handler = function(app) {
Handler.prototype.entry = function(msg, session, next) {
next(null, {code: 200, msg: 'game server is ok.'});
};

/**
* Publish route for mqtt connector.
*
* @param {Object} msg request message
* @param {Object} session current session object
* @param {Function} next next stemp callback
* @return {Void}
*/
Handler.prototype.publish = function(msg, session, next) {
next(null, {code: 200, msg: 'publish message is ok.'});
};

/**
* Subscribe route for mqtt connector.
*
* @param {Object} msg request message
* @param {Object} session current session object
* @param {Function} next next stemp callback
* @return {Void}
*/
Handler.prototype.subscribe = function(msg, session, next) {
next(null, {code: 200, msg: 'subscribe message is ok.'});
};

0 comments on commit 74510dd

Please sign in to comment.