few comments

This commit is contained in:
Marek Kotewicz
2015-01-14 10:50:34 +01:00
parent 422dc05bb0
commit 8d1f96cc0a
2 changed files with 27 additions and 13 deletions

View File

@ -33,6 +33,13 @@ if (process.env.NODE_ENV !== 'build') {
var web3 = require('./web3'); // jshint ignore:line
}
/// Automatically tries to setup correct provider
/// First it checkes if we are ethereum browser (if navigator.qt object is available)
/// if yes, we are using QtProvider
/// if no, we check if it is possible to establish websockets connection with ethereum (ws://localhost:40404/eth is default)
/// if it's not possible, we are using httprpc provider (http://localhost:8080)
/// The constructor allows you to specify uris on which we are trying to connect over http or websockets
/// You can do that by passing objects with fields httrpc and websockets
var AutoProvider = function (userOptions) {
if (web3.haveProvider()) {
return;
@ -81,6 +88,8 @@ var AutoProvider = function (userOptions) {
};
};
/// Sends message forward to the provider, that is being used
/// if provider is not yet set, enqueues the message
AutoProvider.prototype.send = function (payload) {
if (this.provider) {
this.provider.send(payload);
@ -89,6 +98,7 @@ AutoProvider.prototype.send = function (payload) {
this.sendQueue.push(payload);
};
/// On incoming message sends the message to the provider that is currently being used
Object.defineProperty(AutoProvider.prototype, 'onmessage', {
set: function (handler) {
if (this.provider) {