1.0.1 • Published 7 years ago

iota-ws-client v1.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

WebSocket client for IOTA IRI WebSocket proxy server

WebSocket client for IOTA IRI WebSocket proxy server, it support all standard IRI Api command and returns a promise. It can also receive push commands from iota-ws-proxy depending on configuration.

IRI Api commands

Please also see iota-ws-proxy

Usage example

    var client = new WsClient({
        url: 'http://iotanode.net:5000/',
        username: 'admin',
        password: 'iota_is_awesome'
    });

    client.onConnected(() => {
        
        client.getNodeInfo()
            .then((res) => {
                console.log('getNodeInfo', res);
            })
            .catch((e) => {
                console.warn('getNodeInfo error', e);
            });

        client.getNeighbors()
            .then((res) => {
                console.log('getNeighbors', res);
            })
            .catch((e) => {
                console.warn('getNeighbors error', e);
            });

        client.getTips()
            .then((res) => {
                console.log('getTips', res);
            })
            .catch((e) => {
                console.warn('getNeighbors error', e);
            });
    });

    client.onDisconnected(() => {
        console.log('onDisconnected');
    });

    client.onOsUpdate((resp) => {
        console.log(resp.data);
    });

    client.onCommand((resp) => {
        console.log(resp.data);
    });