Coder Social home page Coder Social logo

smpp's Introduction

SMPP 3.4 Library

GoDoc Badge GoReportCard Badge Build Status

smpp is library contains implementation of SMPP 3.4 protocol.

It allows easier creation of SMPP clients and servers by providing utilities for PDU and session handling.

Project Status

Although usable, project is still to be considered as WORK IN PROGRESS until it reaches it's first official version. Util then breaking API to fix possible design flaws is possible.

Project goals

  • Provide API for manipulating and observing PDU data.
  • Provide API for SMPP session handling.
  • Provide reference SMPP SMSC Server implementation.
  • Enforce SMPP specification integrity (to the most useful degree).

Feature description

  • Smpp protocol integrity is enforced with the use of session states.

  • Allow communication over tcp protocol.

  • Pdu data structure should have access to all of it's elements.

  • When client and server are connected session is created.

  • When connection is terminated or unbinding is finished session is closed.

  • Closing can be completed only after graceful handling of all remaining operations.

  • Request window is the number of sent requests during a session that are waiting for the matching response from the other side.

  • Size of the window is configurable if window is closed send should fail.

  • Sending should timeout if response is not received in configured amount of time.

  • Sender should wait for responses only for requests that have matching responses defined by the spec.

  • Client should have an option to listen for outbind requests from server.

  • Server should be able to rate limit client's requests.

  • Session should handle sequence numbers.

  • Provide logging for critical paths.

  • Sessions should be uniquely identifiable.

  • Helpers for sending enquire_link in regular intervals.

  • If an SMPP entity receives an unrecognized PDU/command, it must return a generic_nack PDU indicating an invalid command_id in the command_status field of the header.

  • Provide stats about running session(s):

    • Open sessions
    • Type of sessions
    • Session send window size
    • Session receive window size
    • Session running time
    • Average send/response times
    • Rate of failures
  • Support all PDU commands defined by the specification.

  • Helper functions for common tasks.

Installation

You can use go get:

go get -u github.com/ajankovic/smpp

Usage

In order to do any kind of interaction you first need to create an SMPP Session. Session is the main carrier of the protocol and enforcer of the specification rules.

Naked session can be created with:

// You must provide already established connection and configuration struct.
sess := smpp.NewSession(conn, conf)

But it's much more convenient to use helpers that would do the binding with the remote SMSC and return you session prepared for sending:

// Bind with remote server by providing config structs.
sess, err := smpp.BindTRx(sessConf, bindConf)

And once you have the session it can be used for sending PDUs to the binded peer.

sm := smpp.SubmitSm{
    SourceAddr:      "11111111",
    DestinationAddr: "22222222",
    ShortMessage:    "Hello from SMPP!",
}
// Session can then be used for sending PDUs.
resp, err := sess.Send(p)

Session that is no longer used must be closed:

sess.Close()

If you want to handle incoming requests to the session specify SMPPHandler in session configuration when creating new session similarly to HTTPHandler from net/http package:

conf := smpp.SessionConf{
    Handler: smpp.HandlerFunc(func(ctx *smpp.Context) {
        switch ctx.CommandID() {
        case pdu.UnbindID:
            ubd, err := ctx.Unbind()
            if err != nil {
                t.Errorf(err.Error())
            }
            resp := ubd.Response()
            if err := ctx.Respond(resp, pdu.StatusOK); err != nil {
                t.Errorf(err.Error())
            }
        }
    }),
}

Detailed examples for SMPP client and server can be found in the examples dir.

smpp's People

Contributors

ajankovic avatar sorokinmax avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.