codec

package module
v0.0.0-...-a86be45 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: MIT Imports: 4 Imported by: 5

Documentation

Index

Constants

View Source
const (
	Pkl              = "pkl" // 数据包总长度
	Cmd              = "op"  // 数据包类型(命令类型)
	Seq              = "seq" // 序号(一对请求与响应序号相同)
	HeadLen   uint32 = 12
	PacketMax        = 5120
)

Variables

This section is empty.

Functions

func UnpackHead

func UnpackHead(h []byte) (pkl, cmd, seq uint32)

Types

type AuthConf

type AuthConf struct {
	ISP             string        `yaml:"isp"               json:"isp"`             // 即运营商标识 cmpp、sgip、smgp
	ClientId        string        `yaml:"client-id"         json:"clientId"`        // 即SourceAddr
	LoginName       string        `yaml:"login-name"        json:"loginName"`       // SGIP协议所需服务端分配的用户名
	SharedSecret    string        `yaml:"shared-secret"     json:"sharedSecret"`    // 通讯密码
	Version         byte          `yaml:"version"           json:"version"`         // 见CMPP协议,48表示3.0 即 0x30 = 0011 0000
	NeedReport      byte          `yaml:"need-report"       json:"needReport"`      // 是否需状态报告
	SmsDisplayNo    string        `yaml:"sms-display-no"    json:"smsDisplayNo"`    // 发送号码(后面可拼接子码)
	ServiceId       string        `yaml:"service-id"        json:"serviceId"`       // 运营商分配的服务ID
	DefaultMsgLevel byte          `yaml:"default-msg-level" json:"DefaultMsgLevel"` // 默认短信优先级 (范围1-9)
	FeeUserType     byte          `yaml:"fee-user-type"     json:"feeUserType"`     // 费用相关
	FeeTerminalType byte          `yaml:"fee-terminal-type" json:"FeeTerminalType"` // 费用相关
	FeeTerminalId   string        `yaml:"fee-terminal-id"   json:"feeTerminalId"`   // 费用相关
	FeeType         string        `yaml:"fee-type"          json:"feeType"`         // 费用相关
	FeeCode         string        `yaml:"fee-code"          json:"feeCode"`         // 费用相关
	FixedFee        string        `yaml:"fixed-fee"         json:"fixedFee"`        // 费用相关
	LinkId          string        `yaml:"link-id"           json:"LinkId"`          // 点播业务相关
	MtValidDuration time.Duration `yaml:"mt-valid-duration" json:"mtValidDuration"` // 短信默认有效期,超过下面配置时长后,如果消息未发送,则不再发送
	MaxConns        int           `yaml:"max-conns"         json:"maxConns"`        // 最大连接数
	MtWindowSize    int           `yaml:"mt-window-size"    json:"mtWindowSize"`    // 接收窗口大小,服务端分配
	Throughput      int           `yaml:"throughput"        json:"throughput"`      // 系统最大吞吐,单位tps
}

func Unmarshal

func Unmarshal(jsn []byte) (ac *AuthConf)

type IHead

type IHead interface {
	Logger
	Encode() []byte
	Decode([]byte) error
}

type Logger

type Logger interface {
	Log() []log.Field
}

type MtOptions

type MtOptions struct {
	NeedReport      uint8
	MsgLevel        uint8
	FeeUsertype     uint8
	FeeTerminalType uint8
	ServiceId       string
	FeeTerminalId   string
	FeeType         string
	FeeCode         string
	ValidTime       string
	AtTime          string
	SpSubNo         string
	LinkID          string
}

func LoadMtOptions

func LoadMtOptions(ops ...OptionFunc) *MtOptions

type Operation

type Operation interface {
	ToInt() uint32
	OpLog() log.Field
	String() string
}

type OptionFunc

type OptionFunc func(mtOps *MtOptions)

func MtAtTime

func MtAtTime(t time.Time) OptionFunc

MtAtTime 定时发送时间,格式遵循SMPP3.3协议

func MtAtTimeStr

func MtAtTimeStr(s string) OptionFunc

MtAtTimeStr 定时发送时间,格式:yyMMddHHmmss

func MtFeeCode

func MtFeeCode(s string) OptionFunc

MtFeeCode 资费代码(以分为单位)

func MtFeeTerminalId

func MtFeeTerminalId(id string) OptionFunc

MtFeeTerminalId 计费号码与FeeTerminalType配合使用

func MtFeeTerminalType

func MtFeeTerminalType(t uint8) OptionFunc

MtFeeTerminalType 被计费用户的号码类型,0:真实号码;1:伪码

func MtFeeType

func MtFeeType(s string) OptionFunc

MtFeeType 资费类别 01:对“计费用户号码”免费 02:对“计费用户号码”按条计信息费 03:对“计费用户号码”按包月收取信息费 04:对“计费用户号码”的信息费封顶 05:对“计费用户号码”的收费是由SP实现

func MtFeeUsertype

func MtFeeUsertype(t uint8) OptionFunc

MtFeeUsertype 计费用户类型字段 0:对目的终端MSISDN计费; 1:对源终端MSISDN计费; 2:对SP计费; 3:表示本字段无效,对谁计费参见Fee_terminal_Id 字段。

func MtLinkID

func MtLinkID(s string) OptionFunc

MtLinkID 点播业务使用的LinkID,非点播类业务的MT流程不使用该字段

func MtMsgLevel

func MtMsgLevel(l uint8) OptionFunc

MtMsgLevel 消息优先级

func MtNeedReport

func MtNeedReport(tf uint8) OptionFunc

MtNeedReport 是否需状态报告

func MtServiceId

func MtServiceId(id string) OptionFunc

MtServiceId 业务标识,是数字、字母和符号的组合

func MtSpSubNo

func MtSpSubNo(s string) OptionFunc

MtSpSubNo 拼接到SpNumber后,整体号码最终在用户手机上显示为短消息的主叫号码

func MtValidTime

func MtValidTime(s string) OptionFunc

MtValidTime 存活有效期,格式遵循SMPP3.3协议

func WithMtOptions

func WithMtOptions(opt *MtOptions) OptionFunc

WithMtOptions 设置配置项

type Pdu

type Pdu interface {
	Logger
	Encode() []byte
	Decode(seq uint32, frame []byte) error
}

type RequestPdu

type RequestPdu interface {
	Pdu
	ToResponse(code uint32) Pdu
}

type Sequence32

type Sequence32 interface {
	NextVal() int32
}

Sequence32 32位序号生成器

var B32Seq Sequence32

type Sequence64

type Sequence64 interface {
	NextVal() int64
}

Sequence64 64位序号生成器

var B64Seq Sequence64

type SequenceBCD

type SequenceBCD interface {
	NextVal() []byte
}

SequenceBCD BCD码序号生成器

var BcdSeq SequenceBCD

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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