中國移動短信網關CMPP3.0 C#源代碼:使用示例

中國移動短信網關CMPP3.0 C#源代碼:使用示例

中國移動短信網關CMPP3.0 C#源代碼使用,在上一篇文章中我介紹過cmpp3.0,這段時間因為也做關于
移動短信網關的開發,在這里給大家一個演示如何使用cmpp3.0開發移動短信網關。
Using Tiray.SMS
...

Tiray.SMS.CMPP30 m_CMPP=new Tiray.SMS.CMPP30();
...

//啟動CMPP
m_CMPP=new CMPP30(txt_CMUserName.Text.Trim(),txt_CMPassword.Text.Trim(),txt_CMServerAddress.Text.Trim(),Convert.ToInt32(txt_CMServerPort.Text.Trim()));
m_CMPP.SMSStateChanged+=new SMSEventHandler(OnCMPP);//定義事件處理函數
m_CMPP.StartThread();
...

//終止CMPP
m_CMPP.EndThread();
...

//移動短信網關事件(異步處理)
protected void OnCMPP(Object sender,SMSEventArgs e)??
{
?SMSAsyncEvent ae = new SMSAsyncEvent(ProcessCMPPEvent);
?IAsyncResult ar=null;
?ar = ae.BeginInvoke(e,new AsyncCallback(CMPPAsyncEventCallBack),ae);
}

//異步事件處理函數
protected void ProcessCMPPEvent(SMSEventArgs e)
{
?string strState=string.Empty;
?if(e.State==SMS_STATE.DELIVER)
?{
??CMPP_DELIVER deliver=(CMPP_DELIVER)e.Data;
??...
?}
???
?else if(e.State==SMS_STATE.DELIVER_RESPONSE)
?{
??CMPP_DELIVER_RESP resp=(CMPP_DELIVER_RESP)e.Data;
??...??
?}
?else if(e.State==SMS_STATE.REPORT)
?{
??CMPP_DELIVER deliver=(CMPP_DELIVER)e.Data;
??CMPP_REPORT report=deliver.GetReport();
??...
?}
?else if(e.State==SMS_STATE.SUBMIT)
?{
??CMPP_SUBMIT submit=(CMPP_SUBMIT)e.Data;
??...?
?}
?else if(e.State==SMS_STATE.SUBMIT_RESPONSE)
?{
??CMPP_SUBMIT_RESP resp=(CMPP_SUBMIT_RESP)e.Data;
??...
?}
?else if(e.State==SMS_STATE.ACTIVE_TEST)
?{
??...???
?}
?else if(e.State==SMS_STATE.ACTIVE_TEST_RESPONSE)
?{
??CMPP_ACTIVE_TEST_RESP resp=(CMPP_ACTIVE_TEST_RESP)e.Data;
??...???
?}
?else if(e.State==SMS_STATE.SP_CONNECT)
?{
??CMPP_CONNECT_RESP resp=(CMPP_CONNECT_RESP)e.Data;
??...
?}
?else if(e.State==SMS_STATE.SP_DISCONNECT)
?{
??...???
?}
?else if(e.State==SMS_STATE.DELIVER_ERROR)
?{
??...??
?}
?else if(e.State==SMS_STATE.DELIVER_RESPONSE_ERROR)
?{
??...???
?}
?else if(e.State==SMS_STATE.SUBMIT_ERROR)
?{
??...???
?}
?else if(e.State==SMS_STATE.SUBMIT_RESPONSE_ERROR)
?{
??...???
?}
?else if(e.State==SMS_STATE.ACTIVE_TEST_ERROR)
?{
??...???
?}
?else if(e.State==SMS_STATE.ACTIVE_TEST_RESPONSE_ERROR)
?{
??...???
?}
?else if(e.State==SMS_STATE.SP_CONNECT_ERROR)
?{
??...???
?}
?else if(e.State==SMS_STATE.SP_DISCONNECT_ERROR)
?{
??...???
?}
??
}

//異步事件回調函數
private void CMPPAsyncEventCallBack(IAsyncResult ar)
{
?SMSAsyncEvent ae = (SMSAsyncEvent)ar.AsyncState;
?ae.EndInvoke(ar);
}

//異步短消息發送
CMPPAsyncSubmit s = new CMPPAsyncSubmit(m_CMPP.Submit);
IAsyncResult ar=null;
string[] Destinations=new string[DestinationCount];
for(int i=0;i<DestinationCount;i++)
strDest[i]=Destination[i].ToString();
ar = s.BeginInvoke(Message,Destinations,Source,ServiceID,CODING.GBK,true,(byte)Tiray.SMS.FEE_USER_TYPE.DESTINATION,(byte)Tiray.SMS.FEE_TYPE.ONE,Fee,Source,LinkID,new AsyncCallback(CMPPAsyncSubmitCallBack),s);
...

//異步發送回調函數
private void CMPPAsyncSubmitCallBack(IAsyncResult ar)
{
?CMPPAsyncSubmit s = (CMPPAsyncSubmit) ar.AsyncState;
?s.EndInvoke(ar);
}

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/389177.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/389177.shtml
英文地址,請注明出處:http://en.pswp.cn/news/389177.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

用python進行營銷分析_用python進行covid 19分析

用python進行營銷分析Python is a highly powerful general purpose programming language which can be easily learned and provides data scientists a wide variety of tools and packages. Amid this pandemic period, I decided to do an analysis on this novel coronav…

名稱

命名規則&#xff1a;Go中函數、變量、常量、類型、語句標簽和包的名稱都遵循一個規則&#xff0c;開頭是一個字母或下劃線&#xff0c;后面跟任意字符、數字和下劃線&#xff0c;并區分大小寫。例如&#xff1a;heapSort和HeapSort是不同名稱。關鍵字&#xff1a;Go有25個關鍵…

Alpha沖刺第二天

Alpha第二天 1.團隊成員 鄭西坤 031602542 &#xff08;隊長&#xff09; 陳俊杰 031602504陳順興 031602505張勝男 031602540廖鈺萍 031602323雷光游 031602319蘇芳锃 0316023302.項目燃盡圖 3.項目進展 時間工作內容11月18日UI設計、初步架構搭建11月19日UI設計、服務器的進一…

Tiray.SMSTiray.SMSTiray.SMSTiray.SMSTiray.SMSTiray.SMS

這是2005年6月云南移動短信網關升級到3.0時寫的&#xff0c;在SP那穩定運行了很長時間的。因為SP倒閉了&#xff0c;貼出來給有興趣的朋友參考。優點&#xff1a;支持多線程、滑動窗口、異步發送、全事件模式、自動識別ASCII、GBK、UCS-2缺點&#xff1a;不支持長短信自動分頁、…

水文分析提取河網_基于圖的河網段地理信息分析排序算法

水文分析提取河網The topic of this article is the application of information technologies in environmental science, namely, in hydrology. Below is a description of the algorithm for ranking rivers and the plugin we implemented for the open-source geographic…

請不要更多的基本情節

“If I see one more basic blue bar plot…”“如果我再看到一個基本的藍色條形圖……” After completing the first module in my studies at Flatiron School NYC, I started playing with plot customizations and design using Seaborn and Matplotlib. Much like doodl…

Powershell-獲取DHCP地址租用信息

需求&#xff1a;業務需要獲取現階段DHCP服務器所有地址租用信息。 1.首先查看DHCP相關幫助信息&#xff1a;2.確定執行命令并獲取相關幫助信息&#xff1a;help Get-DhcpServerv4Scope 名稱 Get-DhcpServerv4Scope 語法 Get-DhcpServerv4Scope [[-ScopeId] <ipaddress[]>…

c# 對COM+對象反射調用時地址參數處理 c# 對COM+對象反射調用時地址參數處理

使用反射的方式調用組件里面的方法&#xff0c;經常會遇見一些象地址參數的處理&#xff0c;在C#中表現為ref參數&#xff0c;比如用C#寫了一個裝配件&#xff0c;里面有一個方法openProcedure(string ProcName,int paraCount,ref string[] parameters)&#xff0c;最后有一個r…

android觸摸消息的派發過程

1.觸摸消息是消息獲取模塊直接派發給應用程序的。 2.觸摸消息在處理時&#xff0c; 需要根據觸摸坐標計算該消息應該派發給哪個View/ViewGroup, 在案件取消處理中不存在 該計算過程。 3.沒有類似”系統按鍵”的”系統觸摸鍵”&#xff0c; 應用程序可完全控制觸摸行為。 4.子…

python 交互式流程圖_使用Python創建漂亮的交互式和弦圖

python 交互式流程圖Python中的數據可視化 (Data Visualization in Python) R vs Python is a constant tussle when it comes to what is the best language, according to data scientists. Though each language has it’s strengths, R, in my opinion has one cutting-edg…

機器學習解決什么問題_機器學習幫助解決水危機

機器學習解決什么問題According to Water.org and Lifewater International, out of 57 million people in Tanzania, 25 million do not have access to safe water. Women and children must travel each day multiple times to gather water when the safety of that water …

遞歸原來可以so easy|-連載(3)

本期我們再通過幾個例子&#xff0c;加深遞歸的理解和熟練度。 上期有一個練習題&#xff1a;用遞歸逆序輸出一個包含整型數據的鏈表。 先完成這個練習題。 對于程序員來說&#xff0c;代碼是最好的溝通工具&#xff0c;什么都不說&#xff0c;上代碼&#xff1a; public class…

Viewport3D 類Viewport3D 類Viewport3D 類

.NET Framework 類庫Viewport3D 類更新&#xff1a;2007 年 11 月為三維可視內容提供呈現圖面。命名空間&#xff1a; System.Windows.Controls程序集&#xff1a; PresentationFramework&#xff08;在 PresentationFramework.dll 中&#xff09;用于 XAML 的 XMLNS&#xf…

升級android 6.0系統

How to Fix errors by manually flashing Marshmallow update 鏡像下載for nexus Factory image Step 1: Download the [Marshmallow factory image](http://www.theandroidsoul.com/download-mra58k-android-6-0-marshmallow-update-released-for-nexus-5-nexus-6-nexus-9-n…

AGC 022 B - GCD Sequence

題面在這里&#xff01; 鍛煉腦子的小構造題。。。 一開始被 a[]<30000 且 序列 gcd 1所困擾&#xff0c;但是發現這并沒有什么&#xff0c;因為我接下來發現了一種總是能構造出 序列和是6的倍數的方案。 首先如果 n3 的話輸出樣例&#xff0c;因為只有這種情況沒法用我的方…

最接近原點的 k 個點_第K個最接近原點的位置

最接近原點的 k 個點In this article, I will be explaining to you one of the problems that you may find when tackling questions in data structures and algorithm. You will need some basic knowledge of data structures in order to understand the optimized solut…

網絡瀏覽器如何工作

Behind the scenes of modern Web Browsers現代Web瀏覽器的幕后花絮 The Web Browser is inarguably the most common portal for users to access the web. The advancement of the web browsers (through the series of history) has led many traditional “thick clients”…

讓自己的頭腦極度開放

為什么80%的碼農都做不了架構師&#xff1f;>>> 一. 頭腦封閉和頭腦開放 頭腦封閉 你是否經常有這樣的經歷&#xff0c;在一次會議或者在一次小組討論時&#xff0c;當你提出一個觀點而被別人否定時&#xff0c;你非常急迫地去反駁別人&#xff0c;從而捍衛自己的尊…

簡介DOTNET 編譯原理 簡介DOTNET 編譯原理 簡介DOTNET 編譯原理

簡介DOTNET 編譯原理 相信大家都使用過 Dotnet &#xff0c;可能還有不少高手。不過我還要講講Dotnet的基礎知識&#xff0c;Dotnet的編譯原理。 Dotnet是一種建立在虛擬機上執行的語言&#xff0c;它直接生成 MSIL 的中間語言&#xff0c;再由DotNet編譯器 JIT 解釋映象為本機…

RecyclerView詳細了解

關于RecyclerView大家都不陌生了&#xff0c;它的使用也越來越受歡迎&#xff0c;現在總體了解一下RecyclerView的作用&#xff0c;為什么會有RecyclerView呢&#xff0c;我用ListView也能干所有的事情啊&#xff0c;尺有所短&#xff0c;寸有所長&#xff0c;先來看看Recycler…