4.1.1 • Published 8 years ago
binary-mock-websocket v4.1.1
binary-mock-websocket
Websocket mock creator for binary applications
Installation
npm install --save-dev binary-mock-websocket
Build calls.js
This gulp file will read the calls from calls.js and will create the websocket mock files in the dist folder.
var gulp = require('gulp');
var mockWebsocket = require('binary-mock-websocket');
gulp.task('build', function() {
return gulp.src('./calls.js', {read: false})
.pipe(mockWebsocket)
.pipe(gulp.dest('dist'));
});
gulp.task('default', ['build'], function(){
process.exit(0);
});
Output
dist/
├── database.js
└── websocket.js
Usage with binary-live-api
var LiveApi = require('binary-live-api').LiveApi;
var ws = require('./dist/websocket');
var api = new LiveApi({websocket: ws});
api.getActiveSymbolsBrief().then(function(response){
console.log(response);
});
Example calls.js
module.exports = {
history: {
// errors: {}
// responses: {}
subscriptions: {
r_100: {
func: function r_100(api){
api.getTickHistory('R_100', {
"end": "latest",
"count": 600,
"subscribe": 1
});
},
maxResponse: 4, // optional
stopCondition: function(data){ // optional
// return true to stop saving the stream
return false;
},
}
},
},
authorize: {
// subscriptions: {}
// responses: {}
errors: {
InvalidToken: {
func: function InvalidToken(api){
api.authorize('FakeToken');
}
}
},
},
active_symbols: {
// subscriptions: {}
// errors: {}
responses: {
allActiveSymbols: {
func: function allActiveSymbols(api) {
api.getActiveSymbolsBrief();
}
}
}
},
};
4.1.1
8 years ago
4.1.0
8 years ago
4.0.0
8 years ago
3.0.8
8 years ago
3.0.6
8 years ago
3.0.5
8 years ago
3.0.3
8 years ago
3.0.2
8 years ago
3.0.1
8 years ago
3.0.0
8 years ago
2.1.3
8 years ago
2.1.2
8 years ago
2.1.1
8 years ago
2.1.0
8 years ago
2.0.0
8 years ago
1.4.0
8 years ago
1.3.0
8 years ago
1.2.0
8 years ago
1.1.10
8 years ago
1.1.9
8 years ago
1.1.8
8 years ago
1.1.7
8 years ago
1.1.6
8 years ago
1.1.5
8 years ago
1.1.4
8 years ago
1.1.2
8 years ago
1.1.1
8 years ago
1.0.14
8 years ago
1.0.13
8 years ago
1.0.12
8 years ago
1.0.11
8 years ago
1.0.10
8 years ago
1.0.9
8 years ago
1.0.8
8 years ago
1.0.7
8 years ago
1.0.6
8 years ago
1.0.5
8 years ago
1.0.4
8 years ago
1.0.3
8 years ago
1.0.2
8 years ago
1.0.1
8 years ago
1.0.0
8 years ago