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

latest
Source
npmnpm
Version
0.4.0
Version published
Maintainers
1
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);
});

Arguments

All arguments to API functions at any depth can be Promises.

camelCase vs snake_case

All of Deluge's arguments are snake_case. Any named arguments will be converted to Deluge's snake_keys convention.

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 26 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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.