Skip to content

Commit

Permalink
Use SockJS as default websocket client library
Browse files Browse the repository at this point in the history
  • Loading branch information
AgustinSRG committed Aug 30, 2016
1 parent 3d872ab commit 1219c37
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
"node": "> 4.0.0"
},
"dependencies": {
"websocket": "1.0.23"
"sockjs-client": "1.1.1"
},
"optionalDependencies": {
"sockjs-client": "1.1.1",
"websocket": "1.0.23",
"githubhook": "1.6.1",
"pem": "1.8.3",
"readline-sync": "1.3.0"
Expand Down
12 changes: 9 additions & 3 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,22 @@ class ChatBotApp {

/* Create the bot */
let ShowdownBot = null;
if (this.config.websocketLibrary === 'sockjs') {
if (this.config.websocketLibrary === 'websocket') {
try {
require('websocket');
} catch (e) {
console.log('Installing dependencies... (websocket)');
require('child_process').spawnSync('sh', ['-c', 'npm install websocket'], {stdio: 'inherit'});
}
ShowdownBot = require(Path.resolve(__dirname, 'lib/showdown-ws.js')).Bot;
} else {
try {
require('sockjs-client');
} catch (e) {
console.log('Installing dependencies... (sockjs-client)');
require('child_process').spawnSync('sh', ['-c', 'npm install sockjs-client'], {stdio: 'inherit'});
}
ShowdownBot = require(Path.resolve(__dirname, 'lib/showdown-sockjs.js')).Bot;
} else {
ShowdownBot = require(Path.resolve(__dirname, 'lib/showdown.js')).Bot;
}

this.bot = new ShowdownBot(this.config.bot.server,
Expand Down
File renamed without changes.

0 comments on commit 1219c37

Please sign in to comment.