資源簡介
用c#語言編寫的P2P聊天程序源代碼
很經典的例子,

代碼片段和文件信息
//??Copyright?(c)?Microsoft?Corporation.??All?Rights?Reserved.
using?System;
using?System.ServiceModel.Channels;
using?System.Collections.Generic;
using?System.Collections.objectModel;
using?System.Configuration;
using?System.Net;
using?System.Net.Sockets;
using?System.ServiceModel;
using?System.ServiceModel.Configuration;
using?System.ServiceModel.PeerResolvers;
//?Custom?peer?resolver?client-side?implementation.?Derives?from?PeerResolver?and?delegates?the?actual
//?registration?unregistration?and?resolution?to?the?resolver?service?(which?is?a?separate?application).
//?If?you?are?unfamiliar?with?new?concepts?used?in?this?sample?refer?to?the?WCF?Basic\GettingStarted?sample.
namespace?ChatClientComponent
{
????//?CustomPeerResolver?Service?contract.?It?is?manually?generated?since?svcutil?currently?does?not
????//?support?WSDL?generation?when?EndpointAddress[]?is?used?in?the?service?contract.
????[ServiceContract(Namespace?=?“http://P2PChat“)]
????public?interface?ICustomPeerResolver
????{
????????[OperationContract]
????????int?Register(string?meshId?PeerNodeAddress?nodeAddresses);
????????[OperationContract]
????????void?Unregister(int?registrationId);
????????[OperationContract]
????????void?Update(int?registrationId?PeerNodeAddress?updatedNodeAddress);
????????[OperationContract]
????????PeerNodeAddress[]?Resolve(string?meshId?int?maxAddresses);
????????[OperationContract]
????????List?GetExistingMeshes();
????}
????public?interface?ICustomPeerResolverChannel?:?ICustomPeerResolver?IClientChannel
????{
????}
????public?class?CustomPeerResolver?:?PeerResolver
????{
????????const?string?config?=?“CustomPeerResolverEndpoint“;
????????//?Allow?the?clients?to?share?referals
????????public?override?bool?CanShareReferrals
????????{
????????????get?{?return?true;?}
????????}
????????//?Register?address?for?a?node?participating?in?a?mesh?identified?by?meshId?with?the?resolver?service
????????public?override?object?Register(string?meshId?PeerNodeAddress?nodeAddress?TimeSpan?timeout)
????????{
????????????ChannelFactory?factory?=?new?ChannelFactory(config);
????????????ICustomPeerResolverChannel?client?=?factory.CreateChannel();
????????????MaskScopeId(nodeAddress.IPAddresses);
????????????int?registrationId?=?client.Register(meshId?nodeAddress);
????????????client.Close();
????????????factory.Close();
????????????return?registrationId;
????????}
????????//?Unregister?address?for?a?node?from?the?resolver?service
????????public?override?void?Unregister(object?registrationId?TimeSpan?timeout)
????????{
????????????ChannelFactory?factory?=?new?ChannelFactory(config);
????????????ICustomPeerResolverChannel?client?=?factory.CreateChannel();
????????????client.Unregister((int)registrationId);
????????????client.Close();
????????????factor
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????2899??2006-09-18?10:19??P2Pliaotian\ChatClientComponent\ChatClientComponent.csproj
?????文件???????7416??2006-09-18?10:25??P2Pliaotian\ChatClientComponent\CustomPeerResolver.cs
?????文件????????356??2006-09-20?11:00??P2Pliaotian\ChatClientComponent\obj\ChatClientComponent.csproj.FileList.txt
?????文件??????24576??2006-09-20?09:51??P2Pliaotian\ChatClientComponent\obj\Debug\ChatClientComponent.dll
?????文件??????34304??2006-09-20?09:51??P2Pliaotian\ChatClientComponent\obj\Debug\ChatClientComponent.pdb
?????文件??????87452??2006-09-19?17:24??P2Pliaotian\ChatClientComponent\obj\Debug\ResolveAssemblyReference.cache
?????文件???????5825??2006-09-20?09:51??P2Pliaotian\ChatClientComponent\PeerManager.cs
?????文件???????3660??2006-09-19?10:53??P2Pliaotian\ChatClientComponent\PeerService.cs
?????文件???????1413??2006-09-18?09:15??P2Pliaotian\ChatClientComponent\Properties\AssemblyInfo.cs
?????文件???????2382??2006-09-18?09:56??P2Pliaotian\ChatPeer\ChatPeer.csproj
?????文件????????955??2006-09-18?09:55??P2Pliaotian\ChatPeer\DnsHelper.cs
?????文件???????3668??2006-09-18?09:55??P2Pliaotian\ChatPeer\IPeer.cs
?????文件????????605??2006-09-18?09:55??P2Pliaotian\ChatPeer\IPeerService.cs
?????文件???????1391??2006-09-18?09:25??P2Pliaotian\ChatPeer\Properties\AssemblyInfo.cs
?????文件????????297??2006-09-20?10:11??P2Pliaotian\ChatServer\App.xaml
?????文件????????290??2006-09-20?10:11??P2Pliaotian\ChatServer\App.xaml.cs
?????文件???????1952??2006-09-20?10:47??P2Pliaotian\ChatServer\bin\Debug\App.config
?????文件???????4350??2006-09-20?11:06??P2Pliaotian\ChatServer\ChatServer.csproj
?????文件????????168??2006-09-20?10:42??P2Pliaotian\ChatServer\ChatServer.csproj.user
?????文件???????1925??2006-09-20?11:04??P2Pliaotian\ChatServer\obj\Debug\App.g.cs
?????文件????????254??2006-09-20?11:06??P2Pliaotian\ChatServer\obj\Debug\ChatServer_MarkupCompile.cache
?????文件???????1538??2006-09-20?11:04??P2Pliaotian\ChatServer\obj\Debug\Window1.baml
?????文件???????2663??2006-09-20?11:04??P2Pliaotian\ChatServer\obj\Debug\Window1.g.cs
?????文件???????2052??2006-09-20?10:11??P2Pliaotian\ChatServer\Properties\AssemblyInfo.cs
?????文件???????2401??2006-09-20?10:11??P2Pliaotian\ChatServer\Properties\Resources.cs
?????文件???????5618??2006-09-20?10:11??P2Pliaotian\ChatServer\Properties\Resources.resx
?????文件???????1371??2006-09-20?10:11??P2Pliaotian\ChatServer\Properties\Settings.cs
?????文件????????203??2006-09-20?10:11??P2Pliaotian\ChatServer\Properties\Settings.settings
?????文件???????1360??2006-09-20?10:33??P2Pliaotian\ChatServer\Window1.xaml
?????文件???????1844??2006-09-20?10:58??P2Pliaotian\ChatServer\Window1.xaml.cs
............此處省略95個文件信息
- 上一篇:SQLite操作類C#
- 下一篇:C#.net發送郵件完整源代碼DEMO完整版
評論
共有 條評論