Merge branch 'master' of https://github.com/Dexus/larvitsmpp into Dexus-master

This commit is contained in:
2016-06-23 11:34:51 +02:00
2 changed files with 122 additions and 107 deletions
+9 -2
View File
@@ -3,6 +3,7 @@
var log = require('winston'),
merge = require('utils-merge'),
net = require('net'),
tls = require('tls'),
session = require('./session');
function login() {
@@ -94,7 +95,6 @@ function clientSession(sock, options) {
* @param func callback(err, session)
*/
function client(options, callback) {
var sock = new net.Socket();
if (typeof options === 'function') {
callback = options;
@@ -107,11 +107,18 @@ function client(options, callback) {
'port': 2775,
'username': 'user',
'password': 'pass',
'tls': false,
'enqLinkTiming': 20000 // 20 sec
}, options || {});
if(options && options.tls && option.tls === true){
var sock = new tls.Socket();
} else {
var sock = new net.Socket();
}
log.debug('larvitsmpp: lib/client.js: client() - Connecting to ' + options.host + ':' + options.port);
sock.connect(options.port, options.host, function() {
sock.connect(options, function() {
var session = clientSession(sock, options);
log.info('larvitsmpp: lib/client.js: client() - Connected to ' + sock.remoteAddress + ':' + sock.remotePort);