Socket
Book a DemoInstallSign in
Socket

deluge-rpc-socket

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deluge-rpc-socket

Node.js API for Deluge's Binary Socket RPC API

Source
npmnpm
Version
0.3.1
Version published
Weekly downloads
4
-42.86%
Maintainers
1
Weekly downloads
 
Created
Source

Node.js Deluge RPC Socket

Node.js API for Deluge's RPC API

Setup

yarn add deluge-rpc-socket

Usage

const tls = require('tls');
const DelugeRPC = require('deluge-rpc-socket').default;

const socket = tls.connect(
  58846,
  {
    // Deluge often runs with self-signed certificates
    rejectUnauthorized: false,
  }
);

const rpc = DelugeRPC(socket);

let { result, sent } = rpc.daemon.login('username', 'password');

// Monitor socket status
sent
  .then(() => {
    console.log('Message sent');
  })
  .catch(console.error);

// Responses are resolved. Error responses are rejections.
result.then(console.log).catch(console.error);

// Listen for asynchronous events from daemon
rpc.events.on('delugeEvent', console.log);

// Non fatal decoding errors that indicate something is wrong with the protocol...
rpc.events.on('decodingError', console.log);

Alternate API: Don't throw on error responses

const alt = DelugeRPC(socket, { resolveErrorResponses: true });

let { result, sent } = rpc.request('daemon.info');

sent.then(socketError => {
  console.log(socketError || 'Message sent');
});

result.then(({ error, response }) => {
  console.log(error || response);
});

Development

yarn setup
# Launch a REPL with `DelugeRPC` and `config` available in the context and useful commands in history
yarn start

FAQs

Package last updated on 21 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts