Skip to content

Commit

Permalink
Add WS support for method prefixes (consistency) #305
Browse files Browse the repository at this point in the history
  • Loading branch information
relativityboy committed Jan 8, 2018
1 parent bcc2020 commit cccec39
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/api/transports/ws.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ export default class WsTransport extends Transport {
if (this.startPromise) {
return this.startPromise;
}

this.startPromise = new Promise((resolve, reject) => {
this.ws = new WebSocket(this.options.websocket);
this.ws.onerror = (err) => {
this.startPromise = null;
reject(err);
reject(err);
};
this.ws.onopen = () => {
this.isOpen = true;
Expand All @@ -43,7 +43,7 @@ export default class WsTransport extends Transport {
this.ws.onclose = this.onClose.bind(this);
resolve();
};
});
});
return this.startPromise;
}

Expand All @@ -62,6 +62,10 @@ export default class WsTransport extends Transport {
}

send(api, data, callback) {
return this.sendUri(false, false, api, data, callback);
}

sendUri(uri, methodPrefix, api, data, callback) {
debug('Steem::send', api, data);
return this.start().then(() => {
const deferral = {};
Expand All @@ -85,9 +89,9 @@ export default class WsTransport extends Transport {
startedAt: Date.now(),
message: {
id: data.id || this.id++,
method: 'call',
method: (methodPrefix? methodPrefix + '.' : '') + 'call',
jsonrpc: '2.0',
params: [api, data.method, data.params]
params: [api, data.method, data.params]
}
};
this.inFlight++;
Expand Down

0 comments on commit cccec39

Please sign in to comment.