Skip to content

Commit

Permalink
ws => wss
Browse files Browse the repository at this point in the history
  • Loading branch information
you21979 committed Nov 1, 2016
1 parent 38e653f commit 0abb819
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/constant.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
exports.OPT_TAPI_URL = 'https://api.zaif.jp/tapi';
exports.OPT_APIV1_URL = 'https://api.zaif.jp/api/1';
exports.OPT_WEBSOCKET_URL = 'ws://api.zaif.jp:8888';
exports.OPT_WEBSOCKET_URL = 'wss://ws.zaif.jp:8888';
exports.OPT_LIMIT_SEC = 0.2;
exports.OPT_LIMIT_HOST = 'https://api.zaif.jp';
exports.OPT_TIMEOUT_SEC = 30;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"author": "Yuki Akiyama <you2197901 [at] gmail.com>",
"name": "zaif.jp",
"version": "0.1.8",
"version": "0.1.9",
"private": false,
"dependencies": {
"@you21979/simple-verify" : "0.0.x",
Expand Down
49 changes: 49 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,58 @@ var assert = require('assert');
var les = require("local-echoserver");
var verify = require("@you21979/simple-verify");
var qstring = require("querystring");
var Promise = require("bluebird");
var zaif = require('..');

describe('test', function () {
describe('stream api test', function (done) {
var constant = zaif.Constant;
it('stream', function () {
return les(function(url){
return new Promise(function(resolve,reject){
constant.OPT_WEBSOCKET_URL = url.replace("http://","ws://");
var w = zaif.createStreamApi('btc_jpy', function(data){
w.close()
resolve(data)
})
}).then(function(res){
assert(res.currency_pair === 'mona_jpy')
})
},
function(res, headers, method, url, body){},
3000,
function(ws){
ws.on("connection", function(conn) {
conn.send(JSON.stringify({ asks:
[ [ 17.1, 1576 ],
[ 17.2, 3446 ],
[ 17.3, 4226 ],
[ 19.3, 22232 ] ],
last_price: { action: 'ask', price: 17 },
trades:
[ { currenty_pair: 'mona_jpy',
trade_type: 'ask',
price: 17,
tid: 80618,
amount: 64,
date: 1428130395 },
{ currenty_pair: 'mona_jpy',
trade_type: 'ask',
price: 16.9,
tid: 80505,
amount: 16,
date: 1428117904 } ],
bids:
[ [ 17, 1133 ],
[ 16.9, 2390 ],
[ 15.1, 3862 ] ],
currency_pair: 'mona_jpy',
timestamp: '2015-04-04 16:04:14.000419' })
);
})
})
})
})
describe('private api test', function () {
var constant = zaif.Constant;
var config = {apikey : "",secretkey : "", useragent : "tradebot"}
Expand Down

0 comments on commit 0abb819

Please sign in to comment.