npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

goip

v0.2.0

Published

Simple server and client for goip gateways

Downloads

13

Readme

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} = require('goip');

const server = ServerFactory.make(333);

server.onAll( (message) => {
    console.log(message);
});

server.run();

Example 2

const {ServerFactory, MessageDispatcher, MessageFactory} = require('goip');

const server = ServerFactory.make(333, {
    'address': '0.0.0.0', // server address
    'messageDispatcher': new MessageDispatcher(), // Message Dispatcher implementation
    'messageFactory': new MessageFactory() // Message Factory implementation
});

server.onAll( (message) => {
    console.log(message);
});

server.run();

Register message listener

const {ServerFactory} = require('goip');

const server = ServerFactory.make(333);

// All messages
server.onAll( (message) => {
    console.log(message);
});

// Goip not supported message
server.onNotSupported( (message) => {
    console.log(message);
});

// Keep Alive packets with gateway (line) information
server.onRequest( (message) => {
    console.log(message);
});

// Incoming SMS
server.onReceive( (message) => {
    console.log(message);
});

// SMS delivery report
server.onDeliver( (message) => {
    console.log(message);
});

// End telephone call
server.onHangup( (message) => {
    console.log(message);
});

// Start a phone call
server.onRecord( (message) => {
    console.log(message);
});

// Change of gate (line) status
server.onState( (message) => {
    console.log(message);
});

// Socket server error message
server.onServerError( (message) => {
    console.log(message);
});

server.run();

Sending a message

Sending via UDP socket

Example 1 - sending one message and close the connection
const {SocketSms} = require('goip');

const sms = new SocketSms(
	'192.168.0.11', // Goip address
	9991, // Goip port
	'goip_password' // Goip password
);

sms.sendOne('999999999','test sms message').then( response => {
    console.log(response);
}).catch(error => {
    console.log(error);
});
Example 2 - sending many messages
const {SocketSms} = require('goip');

const sms = new SocketSms(
	'192.168.0.11', // Goip address
	9991, // Goip port
	'goip_password' // Goip password
);

( async () => {

    try {

        const response1 = await sms.send('999999999','test sms message 1');
        const response2 = await sms.send('999999999','test sms message 2');

        console.log(response1);
        console.log(response2);

    } catch (error) {

        console.log(error);

    }

    sms.close();
})();

Sending via HTTP

Example 1 - sending one message
const {HttpSms} = require('goip');

const sms = new HttpSms(
    '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.send('999999999', 'test message').then((response) => {
    console.log(response);
}).catch((error) => {
    console.log(error);
});
Example 2 - sending many messages
const {HttpSms} = require('goip');

const sms = new HttpSms('http://192.168.0.11',1,'login','password',{
    'waitForStatus': true
});

(async () => {

    try {
        const response1 = await sms.send('999999999','test sms message 1');
        const response2 = await sms.send('999999999','test sms message 2');
        console.log(response1);
        console.log(response2);
    } catch (error) {
        console.log(error);
    }

})();
Example 3 - checking status by id
const {HttpSms} = require('goip');
const sms = new HttpSms(
    'http://192.168.0.11', // Goip http address
    1, // Line number
    'login', // Goip login
    'password', // Goip password
);

( async () => {

    try {
        const response = await sms.send('999999999', 'test message');

        console.log(response);

        setTimeout(async () => {
            const isSend = await sms.isSend( response.id );

            if( isSend ) {
                console.log('sms sent')
            }
        
            if( !isSend ) {
                console.log('sms not sent')
            }

        }, 5000);

    } catch (error) {
        console.log(error);
    }

})();