Subscriber

Prerequisites

  • A DPSN account with a registered topic.

  • A delegated address with appropriate permissions.

  • The DPSN SDK for your preferred programming language.

Setting Up the Environment

  1. Install the SDK: Download and install the DPSN SDK for your chosen programming language (e.g., Node.js, Python, Go).

  2. Configure the Environment: Set the DPSN_DELEGATED_ADDRESS_PVTKEY environment variable to the newly created delegated address.

Subscriber Integration

  1. Import the SDK: Import the necessary modules from the DPSN SDK.

  2. Create a Subscriber Instance: Create a new subscriber instance using the SDK.

  3. Subscribe to a Topic: Use the subscribeToTopic function to subscribe to the desired topic.

  4. Handle Incoming Messages: Define a callback function to process incoming messages.

JavaScript

const DPSN = require('dpsn-sdk');

// Create a subscriber instance
const subscriberChannel = new DPSN.Subscriber(process.env.DPSN_DELEGATED_ADDRESS_PVTKEY, 'your_topic');

// Subscribe to a topic
subscriberChannel.subscribeToTopic((message) => {
  processMessage(message);
});

Last updated