資源簡(jiǎn)介
前段時(shí)間在做WCF開(kāi)發(fā)的過(guò)程中,用戶需要在服務(wù)端對(duì)客戶端進(jìn)行監(jiān)控,需要知道客戶端什么時(shí)候上線,什么時(shí)候下線,當(dāng)然服務(wù)端也可以給客戶端推送信息,就是所謂的雙向通信了。 要雙向通信用我以前的HTTP協(xié)議是行不通了,問(wèn)了一下別人,別人說(shuō)了一個(gè)“心跳更新”這個(gè)概念,想必大家都懂這個(gè)吧,大概意思呢就是A向B定時(shí)發(fā)送一個(gè)消息來(lái)監(jiān)測(cè)B是否活著,如果活著就返回一個(gè)消息,死掉當(dāng)然就不需要了,其實(shí)我覺(jué)得心跳更新就是TCP協(xié)議,也就是雙向通信,互相監(jiān)測(cè)活著或者死掉。
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Runtime.Serialization;
using?System.ServiceModel;
using?System.Text;
namespace?WcfServiceLibraryDemo
{
????//?注意:?使用“重構(gòu)”菜單上的“重命名”命令,可以同時(shí)更改代碼和配置文件中的接口名“IService1”。
????[ServiceContract]
????public?interface?IService1
????{
????????[OperationContract]
????????string?GetData(int?value);
????????[OperationContract]
????????CompositeType?GetDataUsingDataContract(CompositeType?composite);
????????//?TODO:?在此添加您的服務(wù)操作
????}
????
????//?使用下面示例中說(shuō)明的數(shù)據(jù)協(xié)定將復(fù)合類型添加到服務(wù)操作
????[DataContract]
????public?class?CompositeType
????{
????????bool?boolValue?=?true;
????????string?stringValue?=?“Hello?“;
????????[DataMember]
????????public?bool?BoolValue
????????{
????????????get?{?return?boolValue;?}
????????????set?{?boolValue?=?value;?}
????????}
????????[DataMember]
????????public?string?StringValue
????????{
????????????get?{?return?stringValue;?}
????????????set?{?stringValue?=?value
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2016-07-04?17:07??WcfServiceTcpDemo\
?????目錄???????????0??2016-06-29?11:36??WcfServiceTcpDemo\WcfServiceLibraryDemo\
?????目錄???????????0??2016-06-29?11:36??WcfServiceTcpDemo\WcfServiceLibraryDemo\bin\
?????目錄???????????0??2016-06-29?11:36??WcfServiceTcpDemo\WcfServiceLibraryDemo\bin\Debug\
?????文件??????294912??2013-05-22?17:21??WcfServiceTcpDemo\WcfServiceLibraryDemo\bin\Debug\MySql.Data.dll
?????文件????????5632??2016-07-05?15:06??WcfServiceTcpDemo\WcfServiceLibraryDemo\bin\Debug\WcfServiceLibraryDemo.dll
?????文件???????17920??2016-07-05?15:06??WcfServiceTcpDemo\WcfServiceLibraryDemo\bin\Debug\WcfServiceLibraryDemo.pdb
?????目錄???????????0??2016-06-29?11:36??WcfServiceTcpDemo\WcfServiceLibraryDemo\bin\Release\
?????文件????????1183??2016-06-28?15:59??WcfServiceTcpDemo\WcfServiceLibraryDemo\IService1.cs
?????目錄???????????0??2016-06-29?11:36??WcfServiceTcpDemo\WcfServiceLibraryDemo\obj\
?????目錄???????????0??2016-07-05?15:06??WcfServiceTcpDemo\WcfServiceLibraryDemo\obj\Debug\
?????文件????????6801??2016-07-05?15:05??WcfServiceTcpDemo\WcfServiceLibraryDemo\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件???????????0??2016-09-02?16:19??WcfServiceTcpDemo\WcfServiceLibraryDemo\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
?????文件???????????0??2016-09-02?16:19??WcfServiceTcpDemo\WcfServiceLibraryDemo\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
?????文件???????????0??2016-09-02?16:19??WcfServiceTcpDemo\WcfServiceLibraryDemo\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
?????目錄???????????0??2016-06-29?11:36??WcfServiceTcpDemo\WcfServiceLibraryDemo\obj\Debug\TempPE\
?????文件????????1116??2016-07-05?15:06??WcfServiceTcpDemo\WcfServiceLibraryDemo\obj\Debug\WcfServiceLibraryDemo.csproj.FileListAbsolute.txt
?????文件????????7672??2016-07-05?15:06??WcfServiceTcpDemo\WcfServiceLibraryDemo\obj\Debug\WcfServiceLibraryDemo.csprojResolveAssemblyReference.cache
?????文件????????5632??2016-07-05?15:06??WcfServiceTcpDemo\WcfServiceLibraryDemo\obj\Debug\WcfServiceLibraryDemo.dll
?????文件???????17920??2016-07-05?15:06??WcfServiceTcpDemo\WcfServiceLibraryDemo\obj\Debug\WcfServiceLibraryDemo.pdb
?????目錄???????????0??2016-06-29?11:36??WcfServiceTcpDemo\WcfServiceLibraryDemo\Properties\
?????文件????????1369??2016-06-28?15:33??WcfServiceTcpDemo\WcfServiceLibraryDemo\Properties\AssemblyInfo.cs
?????文件?????????901??2016-06-28?19:55??WcfServiceTcpDemo\WcfServiceLibraryDemo\Service1.cs
?????文件????????2916??2016-06-28?15:35??WcfServiceTcpDemo\WcfServiceLibraryDemo\WcfServiceLibraryDemo.csproj
?????文件?????????589??2016-06-28?15:35??WcfServiceTcpDemo\WcfServiceLibraryDemo\WcfServiceLibraryDemo.csproj.user
?????文件????????2581??2016-06-28?15:34??WcfServiceTcpDemo\WcfServiceTcpDemo.sln
?????文件???????35840??2016-06-29?10:31??WcfServiceTcpDemo\WcfServiceTcpDemo.suo
?????文件???????69632??2016-09-19?11:26??WcfServiceTcpDemo\WcfServiceTcpDemo.v12.suo
?????目錄???????????0??2016-10-25?19:28??WcfServiceTcpDemo\WinWcf\
?????文件?????????144??2016-06-28?15:44??WcfServiceTcpDemo\WinWcf\app.config
?????目錄???????????0??2016-06-29?11:36??WcfServiceTcpDemo\WinWcf\bin\
............此處省略97個(gè)文件信息
評(píng)論
共有 條評(píng)論