📄 cmpp with c#.txt
字号:
}
public class CancelRespEventArgs:EventArgs
{
private uint _seq;
private MSG.CMPP_MSG_CANCEL_RESP _msg;
public CancelRespEventArgs(uint seq)
{
this._seq =seq;
}
public CancelRespEventArgs(object msg)
{
this._msg =(MSG.CMPP_MSG_CANCEL_RESP) msg;
this._seq =this._msg.Sequence ;
}
public object getMSG()
{
return(this._msg);
}
public uint Sequence
{
set
{
this._seq =value;
}
get
{
return(this._seq );
}
}
}
public class QueryRespEventArgs:EventArgs
{
private uint _seq;
private MSG.CMPP_MSG_QUERY_RESP _msg;
public QueryRespEventArgs(uint seq)
{
this._seq =seq;
}
public QueryRespEventArgs(object msg)
{
this._msg =(MSG.CMPP_MSG_QUERY_RESP)msg;
this._seq =this._msg.Sequence;
}
public object getMSG()
{
return(this._msg);
}
public uint Sequence
{
set
{
this._seq =value;
}
get
{
return(this._seq);
}
}
}
public class ConnectRespEventArgs:EventArgs
{
private uint _seq;
private MSG.CMPP_MSG_CONNECT_RESP _msg;
public ConnectRespEventArgs(uint seq)
{
this._seq =seq;
}
public ConnectRespEventArgs(object msg)
{
this._msg =(MSG.CMPP_MSG_CONNECT_RESP)msg;
this._seq =this._msg.Sequence ;
}
public object getMSG()
{
return(this._msg );
}
public uint Sequence
{
set
{
this._seq =value;
}
get
{
return(this._seq );
}
}
}
public class SubmitRespEventArgs:EventArgs
{
private uint _seq;
private MSG.CMPP_MSG_SUBMIT_RESP _msg;
public SubmitRespEventArgs(uint seq)
{
this._seq =seq;
}
public SubmitRespEventArgs(object msg)
{
this._msg =(MSG.CMPP_MSG_SUBMIT_RESP)msg;
this._seq=this._msg.Sequence ;
}
public object getMSG()
{
return(this._msg );
}
public uint Sequence
{
set
{
this._seq =value;
}
get
{
return(this._seq );
}
}
}
public class WaitingQueueItemEventArgs:EventArgs
{
private uint _seq;
private object _q;
public WaitingQueueItemEventArgs(uint seq)
{
this._seq =seq;
}
public WaitingQueueItemEventArgs(object q)
{
this._q =q;
}
public uint Sequence
{
set
{
this._seq =value;
}
get
{
return(this._seq );
}
}
public object getQueueItem()
{
return(this._q );
}
}
public class ClientQueueStateArgs //当CMPP client的服务停止时候,队列的状态参数
{
private SortedList _waiting;
private SortedList _out;
public ClientQueueStateArgs(SortedList outQueue,SortedList inQueue)
{
this._waiting =inQueue;
this._out =outQueue;
}
public SortedList WaitingQueue
{
get
{
return(this._waiting );
}
set
{
this._waiting =value;
}
}
public SortedList OutQueue
{
get
{
return(this._out );
}
set
{
this._out =value;
}
}
}
public class StateObject
{
public Socket workSocket = null; // Client socket.
public const int BufferSize = 1024; // Size of receive buffer.
public byte[] buffer = new byte[BufferSize]; // Receive buffer.
public byte[] result_buf=null; //接收最终的结果缓冲区
public int _msglength=0; //接收到多少个字节数据
}
public enum SMSDBQueue_Status :int
{
NEW=0, //新消息,等待发送
SENDED=1, //正在发送,等待回应
RESP=2, //送达SMSC,得到msgid
DELIVRD=3, //得到报告,状态ok
EXPIRED=4, //过期
DELETED=5, //已经删除此消息 UNDELIV
ACCEPTD=6, // ACCEPTD 状态 未送达 ACCEPTED为中间状态,网关若从短信中心收到后应丢弃,不做任何操作
UNDELIV=7, //未送达
UNKNOWN=8, //未知
REJECTD=9 //被弹回
}
public class SMSDBQueue
{
private uint _sequence=0; //对应的cmppclient的序列号
private int _smsdbID=0; //对应的数据库的发送自动增长ID
private int _cmpp_msgType; //cmpp协议的定义的消息类型
private object _cmpp_msg_object; //cmpp消息对象,备检索
private int _currentStatus; //当前消息体状态
private DateTime _inQueueTime=DateTime.Now; //消息产生设定值
private UInt64 _msgid; //消息返回的SMSC给出的id遍号
public uint Sequence
{
get
{
return(this._sequence );
}
set
{
this._sequence =value;
}
}
public int SMSDBID
{
get
{
return(this._smsdbID);
}
set
{
this._smsdbID =value;
}
}
public int CurrentStatus
{
get
{
return(this._currentStatus );
}
set
{
this._currentStatus =value;
}
}
public int CMPPMsgType
{
get
{
return(this._cmpp_msgType );
}
set
{
this._cmpp_msgType =value;
}
}
public DateTime InQueueTime
{
get
{
return(this._inQueueTime );
}
set
{
this._inQueueTime =value;
}
}
public object MsgObject
{
get
{
return(this._cmpp_msg_object );
}
set
{
this._cmpp_msg_object =value;
}
}
public UInt64 UIMsgID
{
get
{
return(this._msgid );
}
set
{
this._msgid =value;
}
}
public string MsgID
{
get
{
return(this._msgid.ToString ());
}
set
{
this._msgid =Convert.ToUInt64(value);
}
}
}
//*************工具类结束***********************************
//********************接口类,用于连接对外的短信存储系统**********************
public interface ISMSStore //定义一个存储接口
{
SMSRec[] getSMSsFromStore(); //从外部存储中获取消息
void updateStoreObjec(int storeObjectID,string state); //更新id代表的对象状态,用于监测状态报告
void updateSMSCMsgID(int storeObjectID,UInt64 msgid);
bool addSMS2Store(SMSRec sms); //向store中存储短消息
string getFeeCode(string svccode); //根据svccode返回消息的收费,根据移动参数进行设定
}
public class SMSRec //SMS载数据库中的表达
{
private int _RecID;
private string _feeUser; //计费用户
private int _smsType=0; //短信类型 0 普通文字短信 1 闪烁短信 2 查询命令短信 3 包月短信
private string _svccode; //服务代码
private string _msg; //消息
private string _state; //消息状态
private string _feecode;
private string _spnum;
private string _toUser;
public SMSRec(int recid,string feeuser,string feecode,string svccode,string msg,string spnum)
{
this._RecID =recid;
this._feeUser =feeuser;
this._toUser =feeuser;
this._svccode =svccode;
this._msg =msg;
this._spnum =spnum;
}
public SMSRec(int recid,string feeuser,string touser,string feecode,string svccode,string msg,string spnum)
{
this._RecID =recid;
this._feeUser =feeuser;
this._toUser =touser;
this._svccode =svccode;
this._msg =msg;
this._spnum =spnum;
}
public string SvcCode
{
get
{
return(this._svccode );
}
set
{
this._svccode =value;
}
}
public string FeeCode
{
get
{
return(this._feecode );
}
set
{
this._feecode =value;
}
}
public string FeeUser
{
get
{
return(this._feeUser );
}
set
{
this._feeUser =value;
}
}
private string ToUser
{
get
{
return(this._toUser);
}
set
{
this._toUser=value;
}
}
public string SPNum
{
get
{
return(this._spnum );
}
set
{
this._spnum =value;
}
}
public string Message
{
get
{
return(this._msg );
}
set
{
this._msg =value;
}
}
}
//****************************** 接口类结束 *********************************
//*************************定义 处理数据库接口的SMS系统类,该类对外提供CMPP处理功能***********
//**功能,实现队列监测,处理失败消息、成功消息,处理定时存储更新等抽象功能的组织,将CMPPClient包装提供
public class SMSSystem
{
private ISMSStore dbcls=null;
private CMPPClient client=null;
private string pwd;
private string systemid;
private string spnum;
public void setISMSStoreInterface(ISMSStore ismsstore)
{
dbcls=ismsstore;
}
public SMSSystem(string systemid,string spnum,string password,string cmppserverip,int cmppport)
{
client=new CMPPClient();
client.Init(cm
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -