Documentation ¶
Index ¶
- Constants
- Variables
- func ListenAndServe(addr string, typ Type, t time.Duration, n int32, logWriter io.Writer, ...) error
- type Client
- func (cli *Client) Connect(servAddr, user, password string, timeout time.Duration) error
- func (cli *Client) Disconnect()
- func (cli *Client) RecvAndUnpackPkt(timeout time.Duration) (interface{}, error)
- func (cli *Client) SendReqPkt(packet Packer) (uint32, error)
- func (cli *Client) SendRspPkt(packet Packer, seqId uint32) error
- type Cmpp2ConnRspPkt
- type Cmpp2DeliverReqPkt
- type Cmpp2DeliverRspPkt
- type Cmpp2FwdReqPkt
- type Cmpp2FwdRspPkt
- type Cmpp2SubmitReqPkt
- type Cmpp2SubmitRspPkt
- type Cmpp3ConnRspPkt
- type Cmpp3DeliverReqPkt
- type Cmpp3DeliverRspPkt
- type Cmpp3FwdReqPkt
- type Cmpp3FwdRspPkt
- type Cmpp3SubmitReqPkt
- type Cmpp3SubmitRspPkt
- type CmppActiveTestReqPkt
- type CmppActiveTestRspPkt
- type CmppConnReqPkt
- type CmppReceiptPkt
- type CmppTerminateReqPkt
- type CmppTerminateRspPkt
- type CommandId
- type Conn
- type Handler
- type HandlerFunc
- type OpError
- type Packer
- type Packet
- type Response
- type Server
- type State
- type Type
Constants ¶
const ( CmppActiveTestReqPktLen uint32 = 12 //12d, 0xc CmppActiveTestRspPktLen uint32 = 12 + 1 //13d, 0xd )
Packet length const for cmpp active test request and response packets.
const ( CmppConnReqPktLen uint32 = 4 + 4 + 4 + 6 + 16 + 1 + 4 //39d, 0x27 Cmpp2ConnRspPktLen uint32 = 4 + 4 + 4 + 1 + 16 + 1 //30d, 0x1e Cmpp3ConnRspPktLen uint32 = 4 + 4 + 4 + 4 + 16 + 1 //33d, 0x21 )
Packet length const for cmpp connect request and response packets.
const ( Cmpp2DeliverReqPktMaxLen uint32 = 12 + 233 //245d, 0xf5 Cmpp2DeliverRspPktLen uint32 = 12 + 8 + 1 //21d, 0x15 Cmpp3DeliverReqPktMaxLen uint32 = 12 + 257 //269d, 0x10d Cmpp3DeliverRspPktLen uint32 = 12 + 8 + 4 //24d, 0x18 )
Packet length const for cmpp deliver request and response packets.
const ( Cmpp2FwdReqPktMaxLen uint32 = 12 + 2379 //2277d, 0x957 Cmpp2FwdRspPktLen uint32 = 12 + 8 + 1 + 1 + 1 //23d, 0x17 Cmpp3FwdReqPktMaxLen uint32 = 12 + 2491 //2503d, 0x9c7 Cmpp3FwdRspPktLen uint32 = 12 + 8 + 1 + 1 + 4 //26d, 0x1a )
Packet length const for cmpp fwd request and response packets.
const ( CMPP_HEADER_LEN uint32 = 12 CMPP2_PACKET_MAX uint32 = 2477 CMPP2_PACKET_MIN uint32 = 12 CMPP3_PACKET_MAX uint32 = 3335 CMPP3_PACKET_MIN uint32 = 12 )
const ( Cmpp2SubmitReqPktMaxLen uint32 = 12 + 2265 //2277d, 0x8e5 Cmpp2SubmitRspPktLen uint32 = 12 + 8 + 1 //21d, 0x15 Cmpp3SubmitReqPktMaxLen uint32 = 12 + 3479 //3491d, 0xda3 Cmpp3SubmitRspPktLen uint32 = 12 + 8 + 4 //24d, 0x18 )
Packet length const for cmpp submit request and response packets.
const ( CmppTerminateReqPktLen uint32 = 12 //12d, 0xc CmppTerminateRspPktLen uint32 = 12 //12d, 0xc )
Packet length const for cmpp terminate request and response packets.
const (
CmppReceiptPktLen uint32 = 60 //60d, 0x3c
)
Packet length const for cmpp receipt packet.
Variables ¶
var ( ErrConnIsClosed = errors.New("connection is closed") ErrReadCmdIDTimeout = errors.New("read commandId timeout") ErrReadPktBodyTimeout = errors.New("read packet body timeout") )
Errors for conn operations
var ( ErrnoConnInvalidStruct uint8 = 1 ErrnoConnInvalidSrcAddr uint8 = 2 ErrnoConnAuthFailed uint8 = 3 ErrnoConnVerTooHigh uint8 = 4 ErrnoConnOthers uint8 = 5 ConnRspStatusErrMap = map[uint8]error{ ErrnoConnInvalidStruct: errConnInvalidStruct, ErrnoConnInvalidSrcAddr: errConnInvalidSrcAddr, ErrnoConnAuthFailed: errConnAuthFailed, ErrnoConnVerTooHigh: errConnVerTooHigh, ErrnoConnOthers: errConnOthers, } )
Errors for connect resp status.
var ( ErrnoDeliverInvalidStruct uint8 = 1 ErrnoDeliverInvalidCommandId uint8 = 2 ErrnoDeliverInvalidSequence uint8 = 3 ErrnoDeliverInvalidMsgLength uint8 = 4 ErrnoDeliverInvalidFeeCode uint8 = 5 ErrnoDeliverExceedMaxMsgLength uint8 = 6 ErrnoDeliverInvalidServiceId uint8 = 7 ErrnoDeliverNotPassFlowControl uint8 = 8 ErrnoDeliverOtherError uint8 = 9 DeliverRspResultErrMap = map[uint8]error{ ErrnoDeliverInvalidStruct: errDeliverInvalidStruct, ErrnoDeliverInvalidCommandId: errDeliverInvalidCommandId, ErrnoDeliverInvalidSequence: errDeliverInvalidSequence, ErrnoDeliverInvalidMsgLength: errDeliverInvalidMsgLength, ErrnoDeliverInvalidFeeCode: errDeliverInvalidFeeCode, ErrnoDeliverExceedMaxMsgLength: errDeliverExceedMaxMsgLength, ErrnoDeliverInvalidServiceId: errDeliverInvalidServiceId, ErrnoDeliverNotPassFlowControl: errDeliverNotPassFlowControl, ErrnoDeliverOtherError: errDeliverOtherError, } )
var ( ErrnoFwdInvalidStruct uint8 = 1 ErrnoFwdInvalidCommandId uint8 = 2 ErrnoFwdInvalidSequence uint8 = 3 ErrnoFwdInvalidMsgLength uint8 = 4 ErrnoFwdInvalidFeeCode uint8 = 5 ErrnoFwdExceedMaxMsgLength uint8 = 6 ErrnoFwdInvalidServiceId uint8 = 7 ErrnoFwdNotPassFlowControl uint8 = 8 ErrnoFwdNoPrivilege uint8 = 9 FwdRspResultErrMap = map[uint8]error{ ErrnoFwdInvalidStruct: errFwdInvalidStruct, ErrnoFwdInvalidCommandId: errFwdInvalidCommandId, ErrnoFwdInvalidSequence: errFwdInvalidSequence, ErrnoFwdInvalidMsgLength: errFwdInvalidMsgLength, ErrnoFwdInvalidFeeCode: errFwdInvalidFeeCode, ErrnoFwdExceedMaxMsgLength: errFwdExceedMaxMsgLength, ErrnoFwdInvalidServiceId: errFwdInvalidServiceId, ErrnoFwdNotPassFlowControl: errFwdNotPassFlowControl, ErrnoFwdNoPrivilege: errFwdNoPrivilege, } )
Errors for result in fwd resp.
var ( ErrEmptyServerAddr = errors.New("cmpp server listen: empty server addr") ErrNoHandlers = errors.New("cmpp server: no connection handler") ErrUnsupportedPkt = errors.New("cmpp server read packet: receive a unsupported pkt") )
errors for cmpp server
var ( ErrnoSubmitInvalidStruct uint8 = 1 ErrnoSubmitInvalidCommandId uint8 = 2 ErrnoSubmitInvalidSequence uint8 = 3 ErrnoSubmitInvalidMsgLength uint8 = 4 ErrnoSubmitInvalidFeeCode uint8 = 5 ErrnoSubmitExceedMaxMsgLength uint8 = 6 ErrnoSubmitInvalidServiceId uint8 = 7 ErrnoSubmitNotPassFlowControl uint8 = 8 ErrnoSubmitNotServeFeeTerminalId uint8 = 9 ErrnoSubmitInvalidSrcId uint8 = 10 ErrnoSubmitInvalidMsgSrc uint8 = 11 ErrnoSubmitInvalidFeeTerminalId uint8 = 12 ErrnoSubmitInvalidDestTerminalId uint8 = 13 SubmitRspResultErrMap = map[uint8]error{ ErrnoSubmitInvalidStruct: errSubmitInvalidStruct, ErrnoSubmitInvalidCommandId: errSubmitInvalidCommandId, ErrnoSubmitInvalidSequence: errSubmitInvalidSequence, ErrnoSubmitInvalidMsgLength: errSubmitInvalidMsgLength, ErrnoSubmitInvalidFeeCode: errSubmitInvalidFeeCode, ErrnoSubmitExceedMaxMsgLength: errSubmitExceedMaxMsgLength, ErrnoSubmitInvalidServiceId: errSubmitInvalidServiceId, ErrnoSubmitNotPassFlowControl: errSubmitNotPassFlowControl, ErrnoSubmitNotServeFeeTerminalId: errSubmitNotServeFeeTerminalId, ErrnoSubmitInvalidSrcId: errSubmitInvalidSrcId, ErrnoSubmitInvalidMsgSrc: errSubmitInvalidMsgSrc, ErrnoSubmitInvalidFeeTerminalId: errSubmitInvalidFeeTerminalId, ErrnoSubmitInvalidDestTerminalId: errSubmitInvalidDestTerminalId, } )
Errors for result in submit resp.
var ErrCommandIdInvalid = errors.New("command_Id in Packet data is invalid")
var ErrCommandIdNotSupported = errors.New("command_Id in Packet data is not supported")
var ErrMethodParamsInvalid = errors.New("params passed to method is invalid")
Common errors.
var ErrNotCompleted = errors.New("data not being handled completed")
var ErrRespNotMatch = errors.New("the response is not matched with the request")
var ErrTotalLengthInvalid = errors.New("total_length in Packet data is invalid")
Protocol errors.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client stands for one client-side instance, just like a session. It may connect to the server, send & recv cmpp packets and terminate the connection.
func (*Client) Connect ¶
Connect connect to the cmpp server in block mode. It sends login packet, receive and parse connect response packet.
func (*Client) Disconnect ¶
func (cli *Client) Disconnect()
func (*Client) RecvAndUnpackPkt ¶
RecvAndUnpackPkt receives cmpp byte stream, and unpack it to some cmpp packet structure.
func (*Client) SendReqPkt ¶
SendReqPkt pack the cmpp request packet structure and send it to the other peer.
type Cmpp2ConnRspPkt ¶
type Cmpp2ConnRspPkt struct { Status uint8 AuthIsmg string Version Type Secret string AuthSrc string SeqId uint32 }
Cmpp2ConnRspPkt represents a Cmpp2 connect response packet.
when used in server side(pack), you should initialize it with correct Status, AuthSrc, Secret and Version.
when used in client side(unpack), nothing needed to be initialized. unpack will fill the Status, AuthImsg, Version and SeqId
func (*Cmpp2ConnRspPkt) Pack ¶
func (p *Cmpp2ConnRspPkt) Pack(seqId uint32) ([]byte, error)
Pack packs the Cmpp2ConnRspPkt to bytes stream for server side. Before calling Pack, you should initialize a Cmpp2ConnRspPkt variable with correct Status,AuthenticatorSource, Secret and Version.
func (*Cmpp2ConnRspPkt) Unpack ¶
func (p *Cmpp2ConnRspPkt) Unpack(data []byte) error
Unpack unpack the binary byte stream to a Cmpp2ConnRspPkt variable. Usually it is used in client side. After unpack, you will get SeqId, Status, AuthenticatorIsmg, and Version. Parameter data contains seqId in header and the whole packet body.
type Cmpp2DeliverReqPkt ¶
type Cmpp2DeliverReqPkt struct { MsgId uint64 DestId string ServiceId string TpPid uint8 TpUdhi uint8 MsgFmt uint8 SrcTerminalId string RegisterDelivery uint8 MsgLength uint8 MsgContent string Reserve string //session info SeqId uint32 }
func (*Cmpp2DeliverReqPkt) Pack ¶
func (p *Cmpp2DeliverReqPkt) Pack(seqId uint32) ([]byte, error)
Pack packs the Cmpp2DeliverReqPkt to bytes stream for client side.
func (*Cmpp2DeliverReqPkt) Unpack ¶
func (p *Cmpp2DeliverReqPkt) Unpack(data []byte) error
Unpack unpack the binary byte stream to a Cmpp2DeliverReqPkt variable. After unpack, you will get all value of fields in Cmpp2DeliverReqPkt struct.
type Cmpp2DeliverRspPkt ¶
func (*Cmpp2DeliverRspPkt) Pack ¶
func (p *Cmpp2DeliverRspPkt) Pack(seqId uint32) ([]byte, error)
Pack packs the Cmpp2DeliverRspPkt to bytes stream for client side.
func (*Cmpp2DeliverRspPkt) Unpack ¶
func (p *Cmpp2DeliverRspPkt) Unpack(data []byte) error
Unpack unpack the binary byte stream to a Cmpp2DeliverRspPkt variable. After unpack, you will get all value of fields in Cmpp2DeliverRspPkt struct.
type Cmpp2FwdReqPkt ¶
type Cmpp2FwdReqPkt struct { SourceId string DestinationId string NodesCount uint8 MsgFwdType uint8 MsgId uint64 PkTotal uint8 PkNumber uint8 RegisteredDelivery uint8 MsgLevel uint8 ServiceId string FeeUserType uint8 FeeTerminalId string TpPid uint8 TpUdhi uint8 MsgFmt uint8 MsgSrc string FeeType string FeeCode string ValidTime string AtTime string SrcId string DestUsrTl uint8 DestId []string MsgLength uint8 MsgContent string Reserve string // session info SeqId uint32 }
func (*Cmpp2FwdReqPkt) Pack ¶
func (p *Cmpp2FwdReqPkt) Pack(seqId uint32) ([]byte, error)
Pack packs the Cmpp2FwdReqPkt to bytes stream for client side. Before calling Pack, you should initialize a Cmpp2FwdReqPkt variable with correct field value.
func (*Cmpp2FwdReqPkt) Unpack ¶
func (p *Cmpp2FwdReqPkt) Unpack(data []byte) error
Unpack unpack the binary byte stream to a Cmpp2FwdReqPkt variable. After unpack, you will get all value of fields in Cmpp2FwdReqPkt struct.
type Cmpp2FwdRspPkt ¶
type Cmpp2FwdRspPkt struct { MsgId uint64 PkTotal uint8 PkNumber uint8 Result uint8 // session info SeqId uint32 }
func (*Cmpp2FwdRspPkt) Pack ¶
func (p *Cmpp2FwdRspPkt) Pack(seqId uint32) ([]byte, error)
Pack packs the Cmpp2FwdRspPkt to bytes stream for server side. Before calling Pack, you should initialize a Cmpp2FwdRspPkt variable with correct field value.
func (*Cmpp2FwdRspPkt) Unpack ¶
func (p *Cmpp2FwdRspPkt) Unpack(data []byte) error
Unpack unpack the binary byte stream to a Cmpp2FwdRspPkt variable. After unpack, you will get all value of fields in Cmpp2FwdRspPkt struct.
type Cmpp2SubmitReqPkt ¶
type Cmpp2SubmitReqPkt struct { MsgId uint64 PkTotal uint8 PkNumber uint8 RegisteredDelivery uint8 MsgLevel uint8 ServiceId string FeeUserType uint8 FeeTerminalId string TpPid uint8 TpUdhi uint8 MsgFmt uint8 MsgSrc string FeeType string FeeCode string ValidTime string AtTime string SrcId string DestUsrTl uint8 DestTerminalId []string MsgLength uint8 MsgContent string Reserve string // session info SeqId uint32 }
func (*Cmpp2SubmitReqPkt) Pack ¶
func (p *Cmpp2SubmitReqPkt) Pack(seqId uint32) ([]byte, error)
Pack packs the Cmpp2SubmitReqPkt to bytes stream for client side. Before calling Pack, you should initialize a Cmpp2SubmitReqPkt variable with correct field value.
func (*Cmpp2SubmitReqPkt) Unpack ¶
func (p *Cmpp2SubmitReqPkt) Unpack(data []byte) error
Unpack unpack the binary byte stream to a Cmpp2SubmitReqPkt variable. Usually it is used in server side. After unpack, you will get all value of fields in Cmpp2SubmitReqPkt struct.
type Cmpp2SubmitRspPkt ¶
func (*Cmpp2SubmitRspPkt) Pack ¶
func (p *Cmpp2SubmitRspPkt) Pack(seqId uint32) ([]byte, error)
Pack packs the Cmpp2SubmitRspPkt to bytes stream for Server side. Before calling Pack, you should initialize a Cmpp2SubmitRspPkt variable with correct field value.
func (*Cmpp2SubmitRspPkt) Unpack ¶
func (p *Cmpp2SubmitRspPkt) Unpack(data []byte) error
Unpack unpack the binary byte stream to a Cmpp2SubmitRspPkt variable. Usually it is used in client side. After unpack, you will get all value of fields in Cmpp2SubmitRspPkt struct.
type Cmpp3ConnRspPkt ¶
type Cmpp3ConnRspPkt struct { Status uint32 AuthIsmg string Version Type Secret string AuthSrc string SeqId uint32 }
Cmpp3ConnRspPkt represents a Cmpp3 connect response packet.
when used in server side(pack), you should initialize it with correct Status, AuthSrc, Secret and Version.
when used in client side(unpack), nothing needed to be initialized. unpack will fill the Status, AuthImsg, Version and SeqId
func (*Cmpp3ConnRspPkt) Pack ¶
func (p *Cmpp3ConnRspPkt) Pack(seqId uint32) ([]byte, error)
Pack packs the Cmpp3ConnRspPkt to bytes stream for server side. Before calling Pack, you should initialize a Cmpp3ConnRspPkt variable with correct Status,AuthenticatorSource, Secret and Version.
func (*Cmpp3ConnRspPkt) Unpack ¶
func (p *Cmpp3ConnRspPkt) Unpack(data []byte) error
Unpack unpack the binary byte stream to a Cmpp3ConnRspPkt variable. Usually it is used in client side. After unpack, you will get SeqId, Status, AuthenticatorIsmg, and Version. Parameter data contains seqId in header and the whole packet body.
type Cmpp3DeliverReqPkt ¶
type Cmpp3DeliverReqPkt struct { MsgId uint64 DestId string ServiceId string TpPid uint8 TpUdhi uint8 MsgFmt uint8 SrcTerminalId string SrcTerminalType uint8 RegisterDelivery uint8 MsgLength uint8 MsgContent string LinkId string //session info SeqId uint32 }
func (*Cmpp3DeliverReqPkt) Pack ¶
func (p *Cmpp3DeliverReqPkt) Pack(seqId uint32) ([]byte, error)
Pack packs the Cmpp3DeliverReqPkt to bytes stream for client side.
func (*Cmpp3DeliverReqPkt) Unpack ¶
func (p *Cmpp3DeliverReqPkt) Unpack(data []byte) error
Unpack unpack the binary byte stream to a Cmpp3DeliverReqPkt variable. After unpack, you will get all value of fields in Cmpp3DeliverReqPkt struct.
type Cmpp3DeliverRspPkt ¶
func (*Cmpp3DeliverRspPkt) Pack ¶
func (p *Cmpp3DeliverRspPkt) Pack(seqId uint32) ([]byte, error)
Pack packs the Cmpp3DeliverRspPkt to bytes stream for client side.
func (*Cmpp3DeliverRspPkt) Unpack ¶
func (p *Cmpp3DeliverRspPkt) Unpack(data []byte) error
Unpack unpack the binary byte stream to a Cmpp3DeliverRspPkt variable. After unpack, you will get all value of fields in Cmpp3DeliverRspPkt struct.
type Cmpp3FwdReqPkt ¶
type Cmpp3FwdReqPkt struct { SourceId string DestinationId string NodesCount uint8 MsgFwdType uint8 MsgId uint64 PkTotal uint8 PkNumber uint8 RegisteredDelivery uint8 MsgLevel uint8 ServiceId string FeeUserType uint8 FeeTerminalId string FeeTerminalPseudo string FeeTerminalUserType uint8 TpPid uint8 TpUdhi uint8 MsgFmt uint8 MsgSrc string FeeType string FeeCode string ValidTime string AtTime string SrcId string SrcPseudo string SrcUserType uint8 SrcType uint8 DestUsrTl uint8 DestId []string DestPseudo string DestUserType uint8 MsgLength uint8 MsgContent string LinkId string // session info SeqId uint32 }
func (*Cmpp3FwdReqPkt) Pack ¶
func (p *Cmpp3FwdReqPkt) Pack(seqId uint32) ([]byte, error)
Pack packs the Cmpp3FwdReqPkt to bytes stream for client side. Before calling Pack, you should initialize a Cmpp3FwdReqPkt variable with correct field value.
func (*Cmpp3FwdReqPkt) Unpack ¶
func (p *Cmpp3FwdReqPkt) Unpack(data []byte) error
Unpack unpack the binary byte stream to a Cmpp3FwdReqPkt variable. After unpack, you will get all value of fields in Cmpp3FwdReqPkt struct.
type Cmpp3FwdRspPkt ¶
type Cmpp3FwdRspPkt struct { MsgId uint64 PkTotal uint8 PkNumber uint8 Result uint32 // session info SeqId uint32 }
func (*Cmpp3FwdRspPkt) Pack ¶
func (p *Cmpp3FwdRspPkt) Pack(seqId uint32) ([]byte, error)
Pack packs the Cmpp3FwdRspPkt to bytes stream for server side. Before calling Pack, you should initialize a Cmpp3FwdRspPkt variable with correct field value.
func (*Cmpp3FwdRspPkt) Unpack ¶
func (p *Cmpp3FwdRspPkt) Unpack(data []byte) error
Unpack unpack the binary byte stream to a Cmpp3FwdRspPkt variable. After unpack, you will get all value of fields in Cmpp3FwdRspPkt struct.
type Cmpp3SubmitReqPkt ¶
type Cmpp3SubmitReqPkt struct { MsgId uint64 PkTotal uint8 PkNumber uint8 RegisteredDelivery uint8 MsgLevel uint8 ServiceId string FeeUserType uint8 FeeTerminalId string FeeTerminalType uint8 TpPid uint8 TpUdhi uint8 MsgFmt uint8 MsgSrc string FeeType string FeeCode string ValidTime string AtTime string SrcId string DestUsrTl uint8 DestTerminalId []string DestTerminalType uint8 MsgLength uint8 MsgContent string LinkId string // session info SeqId uint32 }
func (*Cmpp3SubmitReqPkt) Pack ¶
func (p *Cmpp3SubmitReqPkt) Pack(seqId uint32) ([]byte, error)
Pack packs the Cmpp3SubmitReqPkt to bytes stream for client side. Before calling Pack, you should initialize a Cmpp3SubmitReqPkt variable with correct field value.
func (*Cmpp3SubmitReqPkt) Unpack ¶
func (p *Cmpp3SubmitReqPkt) Unpack(data []byte) error
Unpack unpack the binary byte stream to a Cmpp3SubmitReqPkt variable. Usually it is used in server side. After unpack, you will get all value of fields in Cmpp3SubmitReqPkt struct.
type Cmpp3SubmitRspPkt ¶
func (*Cmpp3SubmitRspPkt) Pack ¶
func (p *Cmpp3SubmitRspPkt) Pack(seqId uint32) ([]byte, error)
Pack packs the Cmpp3SubmitRspPkt to bytes stream for Server side. Before calling Pack, you should initialize a Cmpp3SubmitRspPkt variable with correct field value.
func (*Cmpp3SubmitRspPkt) Unpack ¶
func (p *Cmpp3SubmitRspPkt) Unpack(data []byte) error
Unpack unpack the binary byte stream to a Cmpp3SubmitRspPkt variable. Usually it is used in client side. After unpack, you will get all value of fields in Cmpp3SubmitRspPkt struct.
type CmppActiveTestReqPkt ¶
type CmppActiveTestReqPkt struct { // session info SeqId uint32 }
func (*CmppActiveTestReqPkt) Pack ¶
func (p *CmppActiveTestReqPkt) Pack(seqId uint32) ([]byte, error)
Pack packs the CmppActiveTestReqPkt to bytes stream for client side.
func (*CmppActiveTestReqPkt) Unpack ¶
func (p *CmppActiveTestReqPkt) Unpack(data []byte) error
Unpack unpack the binary byte stream to a CmppActiveTestReqPkt variable. After unpack, you will get all value of fields in CmppActiveTestReqPkt struct.
type CmppActiveTestRspPkt ¶
func (*CmppActiveTestRspPkt) Pack ¶
func (p *CmppActiveTestRspPkt) Pack(seqId uint32) ([]byte, error)
Pack packs the CmppActiveTestRspPkt to bytes stream for client side.
func (*CmppActiveTestRspPkt) Unpack ¶
func (p *CmppActiveTestRspPkt) Unpack(data []byte) error
Unpack unpack the binary byte stream to a CmppActiveTestRspPkt variable. After unpack, you will get all value of fields in CmppActiveTestRspPkt struct.
type CmppConnReqPkt ¶
type CmppConnReqPkt struct { SrcAddr string AuthSrc string Version Type Timestamp uint32 Secret string SeqId uint32 }
CmppConnReqPkt represents a Cmpp2 or Cmpp3 connect request packet.
when used in client side(pack), you should initialize it with correct SourceAddr(SrcAddr), Secret and Version.
when used in server side(unpack), nothing needed to be initialized. unpack will fill the SourceAddr(SrcAddr), AuthSrc, Version, Timestamp and SeqId
func (*CmppConnReqPkt) Pack ¶
func (p *CmppConnReqPkt) Pack(seqId uint32) ([]byte, error)
Pack packs the CmppConnReqPkt to bytes stream for client side. Before calling Pack, you should initialize a CmppConnReqPkt variable with correct SourceAddr(SrcAddr), Secret and Version.
func (*CmppConnReqPkt) Unpack ¶
func (p *CmppConnReqPkt) Unpack(data []byte) error
Unpack unpack the binary byte stream to a CmppConnReqPkt variable. Usually it is used in server side. After unpack, you will get SeqId, SourceAddr, AuthenticatorSource, Version and Timestamp.
type CmppReceiptPkt ¶
type CmppReceiptPkt struct { MsgId uint64 Stat string SubmitTime string // YYMMDDHHMM DoneTime string // YYMMDDHHMM DestTerminalId string SmscSequence uint32 }
func (*CmppReceiptPkt) Pack ¶
func (p *CmppReceiptPkt) Pack() ([]byte, error)
Pack packs the CmppReceiptPkt to bytes stream for client side.
func (*CmppReceiptPkt) Unpack ¶
func (p *CmppReceiptPkt) Unpack(data []byte) error
Unpack unpack the binary byte stream to a CmppReceiptPkt variable. After unpack, you will get all value of fields in CmppReceiptPkt struct.
type CmppTerminateReqPkt ¶
type CmppTerminateReqPkt struct { // session info SeqId uint32 }
func (*CmppTerminateReqPkt) Pack ¶
func (p *CmppTerminateReqPkt) Pack(seqId uint32) ([]byte, error)
Pack packs the CmppTerminateReqPkt to bytes stream for client side.
func (*CmppTerminateReqPkt) Unpack ¶
func (p *CmppTerminateReqPkt) Unpack(data []byte) error
Unpack unpack the binary byte stream to a CmppTerminateReqPkt variable. After unpack, you will get all value of fields in CmppTerminateReqPkt struct.
type CmppTerminateRspPkt ¶
type CmppTerminateRspPkt struct { // session info SeqId uint32 }
func (*CmppTerminateRspPkt) Pack ¶
func (p *CmppTerminateRspPkt) Pack(seqId uint32) ([]byte, error)
Pack packs the CmppTerminateRspPkt to bytes stream for client side.
func (*CmppTerminateRspPkt) Unpack ¶
func (p *CmppTerminateRspPkt) Unpack(data []byte) error
Unpack unpack the binary byte stream to a CmppTerminateRspPkt variable. After unpack, you will get all value of fields in CmppTerminateRspPkt struct.
type CommandId ¶
type CommandId uint32
const (
CMPP_REQUEST_MIN, CMPP_RESPONSE_MIN CommandId = iota, 0x80000000 + iota
CMPP_CONNECT, CMPP_CONNECT_RESP
CMPP_TERMINATE, CMPP_TERMINATE_RESP
CMPP_SUBMIT, CMPP_SUBMIT_RESP
CMPP_DELIVER, CMPP_DELIVER_RESP
CMPP_QUERY, CMPP_QUERY_RESP
CMPP_CANCEL, CMPP_CANCEL_RESP
CMPP_ACTIVE_TEST, CMPP_ACTIVE_TEST_RESP
CMPP_FWD, CMPP_FWD_RESP
CMPP_MT_ROUTE, CMPP_MT_ROUTE_RESP CommandId = 0x00000010 - 10 + iota, 0x80000010 - 10 + iota
CMPP_MO_ROUTE, CMPP_MO_ROUTE_RESP
CMPP_GET_MT_ROUTE, CMPP_GET_MT_ROUTE_RESP
CMPP_MT_ROUTE_UPDATE, CMPP_MT_ROUTE_UPDATE_RESP
CMPP_MO_ROUTE_UPDATE, CMPP_MO_ROUTE_UPDATE_RESP
CMPP_PUSH_MT_ROUTE_UPDATE, CMPP_PUSH_MT_ROUTE_UPDATE_RESP
CMPP_PUSH_MO_ROUTE_UPDATE, CMPP_PUSH_MO_ROUTE_UPDATE_RESP
CMPP_GET_MO_ROUTE, CMPP_GET_MO_ROUTE_RESP
CMPP_REQUEST_MAX, CMPP_RESPONSE_MAX
)
type Conn ¶
type Conn struct { net.Conn State State Typ Type // for SeqId generator goroutine SeqId <-chan uint32 // contains filtered or unexported fields }
func (*Conn) RecvAndUnpackPkt ¶
RecvAndUnpackPkt receives cmpp byte stream, and unpack it to some cmpp packet structure.
type HandlerFunc ¶
The HandlerFunc type is an adapter to allow the use of ordinary functions as Cmpp handlers. If f is a function with the appropriate signature, HandlerFunc(f) is a Handler object that calls f.
The first return value indicates whether to invoke next handler in the chain of handlers.
The second return value shows the error returned from the handler. And if it is non-nil, server will close the client connection after sending back the corresponding response.
type OpError ¶
type OpError struct {
// contains filtered or unexported fields
}
OpError is the error type usually returned by functions in the cmpppacket package. It describes the operation and the error which the operation caused.
func NewOpError ¶
type Server ¶
type Server struct { Addr string Handler Handler // protocol info Typ Type T time.Duration // interval betwwen two active tests N int32 // continuous send times when no response back // ErrorLog specifies an optional logger for errors accepting // connections and unexpected behavior from handlers. // If nil, logging goes to os.Stderr via the log package's // standard logger. ErrorLog *log.Logger }