⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mt.bas

📁 中国联通SGIP 2.0协议的源代码 java
💻 BAS
字号:
Attribute VB_Name = "mt"
Option Explicit

Public SequNum As Integer           '记录发送submit后未应答的Submitresp的数量,不大于30


Public Function SendSubmit(sck As Winsock, MySubMt As SubMit) As Long
'发送

'Dim Body() As Byte              '发送的包
Dim tBin() As Byte
Dim tMsgBin1() As Byte             '存放短消息的二进制数组

Dim tStr As String

Dim Msglen As Integer
Dim msg As String
Dim dst_no As String
Dim rcv_no As String
Dim Tbody() As Byte


'Submit命令
With MySubMt
'计算短消息长度
tMsgBin1 = StrConv(.MessageContent, vbFromUnicode)
Msglen = UBound(tMsgBin1) + 1

'总长度'命令'时间'递增序号
SendHead 144 + 20 + Msglen, SGIP_SUBMIT, inc(SeqNo), sck
    
    .SPNumber = "" & Chr(0)             'SP代码
    .UserCount = Chr(1)
    .CorpId = "" & Chr(0)              '企业代码
    If Left(.ServiceType, 2) = "01" Then
        .FeeType = Chr(1)               '计费类型 2 按条  1 免费  3 包月
        .FeeValue = "000000"            '6个字节,单位:分
    Else
        .FeeType = Chr(2)               '计费类型 2 按条  1 免费  3 包月
        .FeeValue = "000010"            '6个字节,单位:分
    End If
    
    .GivenValue = "000000"          '赠送用户话费
    .AgentFlag = Chr(0)             '?代收费标志
    .MorelatetoMTFlag = Chr(0)      '引起MT消息的原因
    .Priority = Chr(0)              '优先级
    .ExpireTime = Chr(0)                '短消息的寿命。取默认值。yymmddhhmmss032+
    .ScheduleTime = Chr(0)              '定时发送时间。取默认值。yymmddhhmmss032+
    .ReportFlag = Chr(0)            '出错时返回状态报告
    .TP_pid = Chr(0)
    .TP_udhi = Chr(0)
    .MessageCoding = Chr(15)         '短消息编码格式 0:ASCII 8:ucs2 15:GBK
    .MessageType = Chr(0)           '消息类型 0:短消息类型
    '.MessageLength = Msglen
    .Reserve = Chr(0)
        
    tStr = _
        .SPNumber & _
        .ChargeNumber & _
        .UserCount & _
        .UserNumber & _
        .CorpId & _
        .ServiceType & _
        .FeeType & _
        .FeeValue & _
        .GivenValue & _
        .AgentFlag & _
        .MorelatetoMTFlag & _
        .Priority & _
        .ExpireTime & _
        .ScheduleTime & _
        .ReportFlag & _
        .TP_pid & _
        .TP_udhi & _
        .MessageCoding & _
        .MessageType
        
    
    '除msg外的消息体
    Tbody = StrConv(tStr, vbFromUnicode)
    sck.SendData Tbody
    'msg长度
    Send_4byte Msglen, sck
    
    '消息msg
    sck.SendData tMsgBin1
    
    '保留
    ReDim Tbody(7)
    Tbody(0) = 0
    sck.SendData Tbody
    
End With

DoEvents
End Function


Public Function SendBind(sck As Winsock) As Long
'发送连接申请

Dim Body() As Byte              '发送的包
Dim tBin() As Byte

Dim tStr As String

Body = HeadMT

'总长度'命令'时间'递增序号
SendHead 61, SGIP_BIND, inc(SeqNo), sck

'Bind命令

With BindMT
    .Login_Type = Chr(1)
    .Login_Name = "name" & Chr(0)
    .Login_Passowrd = "password" & Chr(0)
    .Reserve = Chr(0)
    
    tStr = .Login_Type & .Login_Name & .Login_Passowrd & .Reserve
    tBin = StrConv(tStr, vbFromUnicode)
        
    '消息体
    
    sck.SendData tBin
End With
DoEvents

End Function

Public Function SendUnbind(sck As Winsock) As Long
'发送连接申请

Dim Body() As Byte              '发送的包

Dim tStr As String

'总长度
SendHead 20, SGIP_UNBIND, inc(SeqNo), sck


End Function

Public Function SubMitRespMX(sck As Winsock) As Integer
'分析SMG发送的submit-resp

Dim i As Integer
Dim J As Integer
Dim tmp As String
tmp = ""
Dim Bins() As Byte
sck.GetData Bins, vbByte

i = 0                                      '0~19 消息头
                                  'type类型全局变量
i = Bins(0)
If i = 0 Then
SequNum = SequNum - 1

'命令正确接收
    
End If

    

End Function

Public Function BindRespMX(sck As Winsock) As Integer
'分析SMG的Bind的回复
'Dim Myname As String
'Dim Mypass As String

Dim Bins() As Byte

sck.GetData Bins, vbByte

    BindRespMX = Bins(0)           '
    
End Function


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -