Complete rewrite
This commit is contained in:
@@ -1,3 +1,61 @@
|
||||
# Larv IT SMPP
|
||||
|
||||
A wrapper for the smpp module, trying to make it more user friendly.
|
||||
This is a simplified implementation of the SMPP protocol. It only supports transciever mode and all messages are sent via the "data_sm" command.
|
||||
|
||||
## Server
|
||||
|
||||
This will setup a password less server on localhost, port 2775 and console.log() incomming commands.
|
||||
|
||||
var larvitsmpp = require('larvitsmpp');
|
||||
|
||||
larvitsmpp.server(function(err, serverSession) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
serverSession.on('data', function(data) {
|
||||
console.log('command: ' + data.command);
|
||||
});
|
||||
});
|
||||
|
||||
## Client
|
||||
|
||||
This will setup a client that connects to localhost, port 2775 without username or password and send a message.
|
||||
|
||||
var larvitsmpp = require('larvitsmpp');
|
||||
|
||||
larvitsmpp.client(function(err, clientSession) {
|
||||
clientSession.send({
|
||||
'sender': 46701113311,
|
||||
'receiver': 46709771337,
|
||||
'message': 'Hello world'
|
||||
}, function(err, res) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
if (res) {
|
||||
console.log('Woho! Message sent');
|
||||
} else {
|
||||
console.log('Server did not accept :(');
|
||||
}
|
||||
});
|
||||
|
||||
clientSession.close();
|
||||
});
|
||||
|
||||
## Advanced server
|
||||
|
||||
This example and its comments covers a lot of configuration options.
|
||||
|
||||
var larvitsmpp = require('larvitsmpp');
|
||||
|
||||
larvitsmpp.server(function(err, serverSession) {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
serverSession.on('data', function(data) {
|
||||
console.log('command: ' + data.command);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user