資源簡介
用WCF技術開發的聊天程序。使用net.tcp綁定。雖然其底層離不開Socket技術,但對于我們開發來說,并不需要直接使用Socket相關的類,使得我們編寫通信程序會變得更靈活更輕松更高效。

代碼片段和文件信息
using?System;
using?System.ServiceModel;
namespace?ServiceDef
{
????[ServiceContract]
????public?interface?IService
????{
????????[OperationContract(IsOneWay?=?true)]
????????void?SendMessage(string?msg);
????}
????///?
????///?服務
????///?
????public?class?MyChatService?:?IService
????{
????????///?
????????///?收到消息后引發的事件
????????///?
????????public?event?EventHandler?MessageGot;
????????public?MyChatService()
????????{
????????????MessageGot?+=?new?EventHandler(TestApp.Form1.GetMessageCallBack);
????????}
????????public?void?SendMessage(string?msg)
????????{
????????????if?(MessageGot?!=?null)
????????????{
????????????????MessageGot(this?new?MessageReceiveEventArgs(msg));
????????????}
????????}
????}
????///?
????///?收到消息后引發事件的參數
????///?
????public?class?MessageReceiveEventArgs?:?EventArgs
????{
????????private?string?m_Message?=?string.Empty;
????????public?MessageReceiveEventArgs(string?message)
????????{
????????????this.m_Message?=?message;
????????}
????????public?string?MessageText
????????{
????????????get?{?return?this.m_Message;?}
????????}
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2013-04-04?17:31??WCFTestApp\
?????目錄???????????0??2013-04-05?12:23??WCFTestApp\TestApp\
?????文件????????1292??2013-04-05?11:58??WCFTestApp\TestApp\ba
?????文件????????5005??2013-04-05?12:22??WCFTestApp\TestApp\Form1.cs
?????文件???????13314??2013-04-05?11:16??WCFTestApp\TestApp\Form1.Designer.cs
?????文件????????5817??2013-04-05?11:16??WCFTestApp\TestApp\Form1.resx
?????文件?????????488??2013-04-04?17:31??WCFTestApp\TestApp\Program.cs
?????目錄???????????0??2013-04-04?17:31??WCFTestApp\TestApp\Properties\
?????文件????????1334??2013-04-04?17:31??WCFTestApp\TestApp\Properties\AssemblyInfo.cs
?????文件????????2866??2013-04-04?17:31??WCFTestApp\TestApp\Properties\Resources.Designer.cs
?????文件????????5612??2013-04-04?17:31??WCFTestApp\TestApp\Properties\Resources.resx
?????文件????????1094??2013-04-04?17:31??WCFTestApp\TestApp\Properties\Settings.Designer.cs
?????文件?????????249??2013-04-04?17:31??WCFTestApp\TestApp\Properties\Settings.settings
?????文件????????3820??2013-04-05?10:35??WCFTestApp\TestApp\TestApp.csproj
?????文件?????????911??2013-04-04?17:51??WCFTestApp\WCFTestApp.sln
?????文件???????38400??2013-04-05?12:22??WCFTestApp\WCFTestApp.v11.suo
- 上一篇:pyqt實現虛擬小鍵盤
- 下一篇:DS1302_8位數碼管_仿真.zip
評論
共有 條評論