go-smpp

module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2025 License: MIT

README

<<<<<<< HEAD

smpp

介绍

{以下是 Gitee 平台说明,您可以替换此简介 Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台 无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 https://gitee.com/enterprises}

软件架构

软件架构说明

安装教程
  1. xxxx
  2. xxxx
  3. xxxx
使用说明
  1. xxxx
  2. xxxx
  3. xxxx
参与贡献
  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request
特技
  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. Gitee 官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
  4. GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
  5. Gitee 官方提供的使用手册 https://gitee.com/help
  6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/ =======

SMPP 3.4

GoDoc Go Report Card Build Status

This is an implementation of SMPP 3.4 for Go, based on the original smpp34 from Kevin Patel.

The API has been refactored to idiomatic Go code with more tests and documentation. There are also quite a few new features, such as a test server (see smpptest package) and support for text transformation for LATIN-1 and UCS-2.

It is not fully compliant, there are some TODOs in the code.

Usage

Following is an SMPP client transmitter wrapped by an HTTP server that can send Short Messages (SMS):

func main() {
    // make persistent connection
    tx := &smpp.Transmitter{
        Addr:   "localhost:2775",
        User:   "foobar",
        Passwd: "secret",
    }
    conn := tx.Bind()
    // check initial connection status
    var status smpp.ConnStatus
    if status = <-conn; status.Error() != nil {
        log.Fatalln("Unable to connect, aborting:", status.Error())
    }
    log.Println("Connection completed, status:", status.Status().String())
    // example of connection checker goroutine
    go func() {
        for c := range conn {
            log.Println("SMPP connection status:", c.Status())
        }
    }()
    // example of sender handler func
    http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
        sm, err := tx.Submit(&smpp.ShortMessage{
            Src:      r.FormValue("src"),
            Dst:      r.FormValue("dst"),
            Text:     pdutext.Raw(r.FormValue("text")),
            Register: pdufield.NoDeliveryReceipt,
            TLVFields: pdutlv.Fields{
                pdutlv.TagReceiptedMessageID: pdutlv.CString(r.FormValue("msgId")),
            },
        })
        if err == smpp.ErrNotConnected {
            http.Error(w, "Oops.", http.StatusServiceUnavailable)
            return
        }
        if err != nil {
            http.Error(w, err.Error(), http.StatusBadRequest)
            return
        }
        io.WriteString(w, sm.RespID())
    })
    log.Fatal(http.ListenAndServe(":8080", nil))
}

You can test from the command line:

curl localhost:8080 -X GET -F src=bart -F dst=lisa -F text=hello

If you don't have an SMPP server to test, check out Selenium SMPPSim. It has been used for the development of this package.

Tools

See the tools under cmd/. There's a command line tool for sending SMS from the command line, and an HTTP server with WebSocket support.

Supported PDUs

  • bind_transmitter
  • bind_transmitter_resp
  • bind_receiver
  • bind_receiver_resp
  • bind_transceiver
  • bind_transceiver_resp
  • outbind
  • unbind
  • unbind_resp
  • submit_sm
  • submit_sm_resp
  • submit_sm_multi
  • submit_sm_multi_resp
  • data_sm
  • data_sm_resp
  • deliver_sm
  • deliver_sm_resp
  • query_sm
  • query_sm_resp
  • cancel_sm
  • cancel_sm_resp
  • replace_sm
  • replace_sm_resp
  • enquire_link
  • enquire_link_resp
  • alert_notification
  • generic_nack
  • tag-length-value (TLV)

See LICENSE and AUTHORS files for details.

664de76 (初次提交)

Directories

Path Synopsis
cmd
sms
SMPP client for the command line.
SMPP client for the command line.
Package smpp is an implementation of the SMPP 3.4 protocol.
Package smpp is an implementation of the SMPP 3.4 protocol.
pdu
Package pdu provide codecs for binary PDU data.
Package pdu provide codecs for binary PDU data.
pdu/pdufield
Package pdufield provides PDU field codecs and utilities.
Package pdufield provides PDU field codecs and utilities.
pdu/pdutext
Package pdutext provides text conversion for PDU fields.
Package pdutext provides text conversion for PDU fields.
smpptest
Package smpptest provides an SMPP test server.
Package smpptest provides an SMPP test server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL