vhd-smpp-module-v1 v1.2.2
/*
- @Author: John Paul Babu john@jondevops.dev
- @Date: 2023-07-26 12:00:00
- @Last Modified by: John Paul Babu john@johndevops.dev
- @Last Modified time: 2023-07-26 12:15:00 */
Vhd Smpp Module 1.0
This is a Node.js module for handling SMPP (Short Message Peer-to-Peer) connections to send and receive SMS messages. It provides an easy-to-use interface to interact with the SMPP server.
Installation
To use this module, you need to have Node.js installed on your system. You can install the module using npm:
npm install smpp
npm install async
Constructor Parameters
port: The port number of the SMPP server. host: The host address of the SMPP server. username: The username for authenticating with the SMPP server. password: The password for authenticating with the SMPP server. autoEnquirePeriod: The period (in milliseconds) for auto-enquiring the link. Default value is 10000 (10 seconds).
Usage
- To use the VhdSmpp module, follow these steps:
Import the module in your code:
const VhdSmpp = require('./path/to/vhd-smpp.js');
- Create an instance of the VhdSmpp class with the required parameters:
const port = 2775; // Port number of the SMPP server
const host = 'smpp.server.com'; // Host address of the SMPP server
const username = 'your_username'; // Your SMPP server username
const password = 'your_password'; // Your SMPP server password
const smppClient = new VhdSmpp(port, host, username, password);
- Initialize event listeners for the SMPP session:
smppClient.initListners();
- Connect to the SMPP server:
smppClient.connect();
5.Bind the SMPP session:
smppClient.bindSmpp();
6.Send an SMS message
const smsOptions = {
destination: 'recipient_number', // Recipient's phone number
message: 'Your SMS message goes here', // The SMS content
source: 'your_source_number', // (optional) Sender's phone number
scheduleDelivery: 'scheduled_date_time' // (optional) Schedule the SMS delivery
};
smppClient.sendMessage(smsOptions, (response) => {
console.log(response); // Handle the response from the SMPP server
});
```bash
7. Define event handlers for specific events:
```bash
smppClient.onEvent('event_name', (data) => {
// Handle the event with the received data
});
- Disconnect from the SMPP server when done:
smppClient.disconnect();
Auto Enquire Link Period
The autoEnquirePeriod parameter specifies the period (in milliseconds) for auto-enquiring the link. This feature helps in keeping the connection alive with the SMPP server. The default value is set to 10000 milliseconds (10 seconds). You can adjust this value as per your requirements during the initialization of the VhdSmpp instance.