{"_id":"@atis/smpp","_rev":"3-4cb3e79cbbd37486822c39b793106ce0","name":"@atis/smpp","description":"SMPP client and server implementation in node.js","dist-tags":{"latest":"0.2.0"},"versions":{"0.2.0":{"name":"@atis/smpp","version":"0.2.0","description":"SMPP client and server implementation in node.js","author":{"name":"Ali Farhadi","email":"a.farhadi@gmail.com"},"engines":{"node":">=0.10.0"},"main":"./lib/smpp","repository":{"type":"git","url":"git+https://github.com/farhadi/node-smpp.git"},"license":"MIT","scripts":{"test":"mocha"},"devDependencies":{"mocha":"2.x"},"dependencies":{"iconv-lite":"0.x"},"gitHead":"9f846f49aa7b8d86d3cb54ef6149f4595efaaa04","bugs":{"url":"https://github.com/farhadi/node-smpp/issues"},"homepage":"https://github.com/farhadi/node-smpp#readme","_id":"@atis/smpp@0.2.0","_shasum":"48eb9b968eebcd85978caeb020484e8f329e4d54","_from":".","_npmVersion":"3.8.6","_nodeVersion":"6.1.0","_npmUser":{"name":"atis","email":"atis@aol.es"},"dist":{"shasum":"48eb9b968eebcd85978caeb020484e8f329e4d54","tarball":"https://registry.npmjs.org/@atis/smpp/-/smpp-0.2.0.tgz","integrity":"sha512-RloU4rDZTJ8QKmqxqvYmzuYaBruJxkKPF96SvG6W/uFUJLbV2WvX0EZbYH5KmEyqhqQhJsCgM6hphYH2hWtFpQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIENOOxWhCre6Ir2dKlEogvYMBDYXKV+3jmIvkWjSCPh7AiEA1Kgeb7HnrNOwfuRCItT8nGkk/2Y0Kfe8uirkdIg5CJo="}]},"maintainers":[{"name":"atis","email":"atis@aol.es"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/smpp-0.2.0.tgz_1463570504118_0.5505344816483557"}}},"readme":"node-smpp\n=========\nSMPP client and server implementation in node.js.\n\n[![Build Status](https://travis-ci.org/farhadi/node-smpp.png)](https://travis-ci.org/farhadi/node-smpp)\n\nIntroduction\n------------\nThis is a complete implementation of SMPP v5.0 in node.js, with support for\ncustom commands and TLVs.\n\nSMPP v5.0, by design, is backward compatible with v3.4, so you would be able to\nuse this module with 3.4 implementations. Even you can use this module with 3.3\nimplementations as far as you don't use TLV parameters and don't bind in transceiver mode.\n\nThe name of the methods and parameters in this implementation are equivalent to\nthe names defined in SMPP specification. So get a copy of\n[SMPP v5.0 Specification](http://farhadi.ir/downloads/smppv50.pdf)\nfor a list of available operations and their parameters.\n\nInstallation\n------------\n\n    npm install smpp\n\nUsage\n-----\n### Creating a SMPP session\n\n``` javascript\nvar smpp = require('smpp');\nvar session = smpp.connect('example.com', 2775);\nsession.bind_transceiver({\n\tsystem_id: 'YOUR_SYSTEM_ID',\n\tpassword: 'YOUR_PASSWORD'\n}, function(pdu) {\n\tif (pdu.command_status == 0) {\n\t\t// Successfully bound\n\t\tsession.submit_sm({\n\t\t\tdestination_addr: 'DESTINATION NUMBER',\n\t\t\tshort_message: 'Hello!'\n\t\t}, function(pdu) {\n\t\t\tif (pdu.command_status == 0) {\n\t\t\t\t// Message successfully sent\n\t\t\t\tconsole.log(pdu.message_id);\n\t\t\t}\n\t\t});\n\t}\n});\n```\n\n### Creating a SMPP server\n\n``` javascript\nvar smpp = require('smpp');\nvar server = smpp.createServer(function(session) {\n\tsession.on('bind_transceiver', function(pdu) {\n\t\t// we pause the session to prevent further incoming pdu events,\n\t\t// untill we authorize the session with some async operation.\n\t\tsession.pause();\n\t\tcheckAsyncUserPass(pdu.system_id, pdu.password, function(err) {\n\t\t\tif (err) {\n\t\t\t\tsession.send(pdu.response({\n\t\t\t\t\tcommand_status: smpp.ESME_RBINDFAIL\n\t\t\t\t}));\n\t\t\t\tsession.close();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsession.send(pdu.response());\n\t\t\tsession.resume();\n\t\t});\n\t});\n});\nserver.listen(2775);\n```\n\nEncodings\n---------\n\nThis smpp implementation supports 3 encodings: `ASCII` (GSM 03.38), `LATIN1`, and `UCS2`.\nRespective data_coding for these encodings are `0x01`, `0x03`, and `0x08`.\n\nDefault encoding for `data_coding:0` is `ASCII`. You can change it as follows:\n\n``` javascript\nsmpp.encodings.default = 'LATIN1';\n```\n\nString messages will be automatically encoded using one of these three encodings.\nIf the SMSC you are communicating with doesn't support one of these encodings,\nyou can simply remove it as follows:\n\n``` javascript\ndelete smpp.encodings.ASCII;\n```\n\nYou can also manually convert a message to a buffer and pass it as `short_message`\nor `message_payload` parameter to bypass automatic message encoding.\n\nAPI\n-------\n\n### smpp.connect([host], [port])\nCreates a new smpp session to the given `host` and `port`. If `port` is omited,\nthe default smpp port (2775) will be used. If `host` is also omitted, `localhost`\nwill be assumed.\n\n### smpp.Session\nThis is the base object for a SMPP session. sessions can be created by calling\n`smpp.connect()` or can be created by a smpp server when a client\nestablishes a connection to the server. In this case the server passes the\nsession object to the `'session'` event listener.\n\n#### session.send(pdu, [responseCallback], [sendCallback])\nSends a pdu request/response to the MC/ESME over the session.\nThe `pdu` is an instance of `smpp.PDU` which might be either a response or\na request pdu.\n\nWhen sending a request pdu, `pdu.sequence_number` will be automatically set to\nthe proper value.\n\nIf the `pdu` is a request pdu, when the relevant response is received, the\noptional `responseCallback` parameter will be invoked with the response pdu passed to it.\n\nOptional `sendCallback` will be called when the pdu is flushed.\n\n#### session.close([callback])\nCloses the current session connection.\nIf supplied, the `callback` is called once the session is fully closed.\n\n#### session.connect()\nCan be used to reconnect a closed connection.\n\n#### session.pause()\nCan be used to postpone incoming pdu events untill calling `session.resume()`.\n\n#### session.resume()\nResumes the session after a call to `pause()`.\n\n#### Shortcut methods\nFor all smpp operations you can call methods with the same name as the operation\nname, which is equivalent to createing a pdu instance and then sending it over\nthe session.\n\nFor example calling `session.submit_sm(options, callback)` is equivalent to:\n\n``` javascript\nvar pdu = new smpp.PDU('submit_sm', options);\nsession.send(pdu, callback);\n```\n\n#### Event: 'connect'\nEmitted when the session connection successfully is established.\n\n#### Event: 'close'\nEmitted when the connection is fully closed.\n\n#### Event: 'error' `(error)`\nEmitted when an error occurs. The `'close'` event will be called directly\nfollowing this event.\n\n#### Event: 'send' `(pdu)`\nEmitted when a pdu is being sent over the session with the pdu as the argument.\n\n#### Event: 'pdu' `(pdu)`\nEmitted upon receiving a pdu.\n\n#### Event: 'unknown' `(pdu)`\nEmitted upon receiving an unknown pdu.\n\n#### Shortcut events\nWhen a pdu is received, after emitting the `'pdu'` event, an event with the same\nname as the operation of that pdu will also be emitted.\n\n### smpp.createServer([sessionListener])\nCreates a new SMPP server. The `sessionListener` argument is automatically set\nas a listener for the 'session' event.\n\n### smpp.Server\nThe base object for a SMPP server created with `smpp.createServer()`.\nIt is a child class of node's `net.Server`.\n\n#### server.listen([port], [host], [callback])\nBegin accepting connections on the specified `port` and `host`. If `port` is\nomitted 2775 will be used. If the `host` is omitted, the server will accept\nconnections directed to any IPv4 address.\n\nThis function is asynchronous. The last parameter `callback` will be called when\nthe server has been bound.\n\n#### Event: 'session' `(session)`\nEmitted when a new session connection is established.\n`session` is an instance of `smpp.Session`.\n\n*for other server methods/events documentations see node's `net.Server` docs.*\n\n### smpp.PDU\nThis is the base object for a PDU request or response.\n\n#### new smpp.PDU(command, [options])\nCreates a new PDU object with the specified `command` and `options`.\n\n`options` is a list of parameters acceptable by the specified `command`.\nThe name of the parameters are equivalent to the names specified in SMPP\nspecification v5.0. The order of the parameters doesn't matter. If you don't\nspecify a required parameter in `options` a default value (usually null or 0 for\nintegers) will be used.\n\nFor the type of the parameters note the following rules:\n\n* For `Integer` parameters (no matter what the length is) you must specify a\nvalue of type `number` in JavaScript.\n* For `Octet-String` and `COctet-String` parameters you can specify either a\n`Buffer` or a `String`.\n* For the fields that accept SMPP Time Format (`broadcast_end_time`,\n`schedule_delivery_time`, `validity_period`, `final_date`) you can specify a\nJavascript Date instance which will be automatically converted to a SMPP\nabsolute time string. For relative times you don't need to specify the whole\nstring, specifying a portion of it is enough. for example '0430' will be\nconverted to '000000000430000R'.\n* For `short_message` and `message_payload` fields you can specify a buffer or a\nstring or an object containing `udh` and `message` properties, while `udh` is a\nbuffer and `message` is either a string or a buffer. strings will be\nautomatically encoded using ASCII, LATIN1, or UCS2 depending on their characters.\n`data_coding` (if not specified) will be automatically set to 0x01, 0x03, or 0x08\nfor ASCII, LATIN1, and UCS2 encodings respectively. Also UDH indicator bit in\n`esm_class` is automatically set if `udh` exists.\n* `sm_length` parameter is not needed. It will be automatically set depending on\nthe length of the `short_message`.\n* `dest_address` parameter in `submit_multi` operation must be an array of\nobjects containing either `dest_addr_ton`, `dest_addr_npi` and,\n`destination_addr` properties or `dl_name` property for SME addresses or\nDistribution Lists respectively.\n* `unsuccess_sme` parameter in `submit_multi_resp` operation must be an array of\nobjects containing `dest_addr_ton`, `dest_addr_npi`, `destination_addr` and,\n`error_status_code` properties.\n* `number_of_dests` and `no_unsuccess` parameters are not needed. They will be\nautomatically set depending on the `dest_address` and `unsuccess_sme` parameters\nrespectively.\n* TLV parameters which can be specified multiple times\n(e.g. `broadcast_area_identifier`), must be specified as an array, even if you\nwant to specifiy just one item.\n\n#### pdu.isResponse()\nReturns `true` if the pdu is a response pdu, otherwise returns false;\n\n#### pdu.response([options])\nFor a request pdu, calling `response()` creates and returns a response pdu for\nthat request.\n\nFor an unknown pdu, `response()` creates and returns a `generic_nack` pdu.\n\n``` javascript\nsession.on('submit_sm', function(pdu) {\n\tvar msgid = .... ; // generate a message_id for this message.\n\tsession.send(pdu.response({\n\t\tmessage_id: msgid\n\t}));\n});\n\nsession.on('unbind', function(pdu) {\n\tsession.send(pdu.response());\n\tsession.close();\n});\n\nsession.on('enquire_link', function(pdu) {\n\tsession.send(pdu.response());\n});\n```\n\nRoadmap\n-------\n* Support for secure sessions using TLS.\n* More test coverage.\n\nLicense\n-------\nnode-smpp is released under the MIT license.\n","maintainers":[{"name":"atis","email":"atis@aol.es"}],"time":{"modified":"2022-06-12T14:49:59.468Z","created":"2016-05-18T11:21:46.557Z","0.2.0":"2016-05-18T11:21:46.557Z"},"homepage":"https://github.com/farhadi/node-smpp#readme","repository":{"type":"git","url":"git+https://github.com/farhadi/node-smpp.git"},"author":{"name":"Ali Farhadi","email":"a.farhadi@gmail.com"},"bugs":{"url":"https://github.com/farhadi/node-smpp/issues"},"license":"MIT","readmeFilename":"README.md"}