This package allow to send and receive SMS messages using GSM / VOIP Goip1, Goip4, Goip8, Goip16 gateways from Hybertone / Dbltek company. SMS can be received via the UDP protocol. The SMS can be sent via UDP or HTTP. Additionally, it is possible to receive basic information about the state and status of individual GSM gates (lines).
Installation
npm install goip
Server usage instruction
To start receiving messages from Goip gateways you need to create and start a server.
Example 1
const ServerFactory HttpSms SocketSms = ; const server = ServerFactory; server; server;
Example 2
const ServerFactory MessageDispatcher MessageFactory = ; const server = ServerFactory; server; server;
Register message listener
const ServerFactory = ; const server = ServerFactory; // All messagesserver; // Goip not supported messageserver; // Keep Alive packets with gateway (line) informationserver; // Incoming SMSserver; // SMS delivery reportserver; // End telephone callserver; // Start a phone callserver; // Change of gate (line) statusserver; // Socket server error messageserver; server;
Sending a message
Sending via UDP socket
Example 1 - sending one message and close the connection
const SocketSms = ; const sms = '192.168.0.11' // Goip address 9991 // Goip port 'goip_password' // Goip password; sms;
Example 2 - sending many messages
const SocketSms = ; const sms = '192.168.0.11' // Goip address 9991 // Goip port 'goip_password' // Goip password; async { try const response1 = await sms; const response2 = await sms; console; console; catch error console; sms;};
Sending via HTTP
Example 1 - sending one message
const HttpSms = ; const sms = 'http://192.168.0.11' // Goip http address 1 // Line number 'login' // Goip login 'password' // Goip password 'waitForStatus': false // Wait and check sending status 'waitTries': 10 // Number of attempts 'waitTime': 1000 // Time in milliseconds ; sms;
Example 2 - sending many messages
const HttpSms = ; const sms = 'http://192.168.0.11'1'login''password' 'waitForStatus': true; async { try const response1 = await sms; const response2 = await sms; console; console; catch error console; };
Example 3 - checking status by id
const HttpSms = ;const sms = 'http://192.168.0.11' // Goip http address 1 // Line number 'login' // Goip login 'password' // Goip password; async { try const response = await sms; console; ; catch error console; };