资源简介
用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完整版
相关资源
- C#.net发送邮件完整源代码DEMO完整版
- SQLite操作类C#
- C#的GDI+绘制图形分层拖放操作源码
- C#调用Ansys二次开发
- 超漂亮的C#登录窗口动画效果
- C#将jpg格式图像转换为数据流,数据流
- 双滑块控件.rar
- c# 验证码识别源代码
- C# 实现Windows任务管理器源代码
- TINdelaunay三角网生成算法
- 最完整的一套C#读取与写入GIS地图数据
- C#实现的表达式解析与计算动态库TE
- C#贪吃蛇C#贪吃蛇C#贪吃蛇
- 写字板C#写的windows窗体编程
- c# 图像 图像放大 图像放大缩小 以鼠
- Visual C#.NET串口通信及测控应用典型超
- C#实现图像腐蚀运算、膨胀运算、开运
- C#建立最简单的Web服务,无需IIS
- [免积分]C#制作的Winform窗体设计器(仿
- C#+ComboBox联想输入+代码类
- 比较完善的C#中调用mapx教程
- C# 课程设计 员工管理信息系统 案例
- asp.net做的酒店客房管理系统
- c# 哈夫曼编码 压缩文件
- C#源码-影院售票系统
- C# winform 子窗体调用父窗体函数实现关
- C#实现KD树 K近邻搜索
- 用C#做个简单的计时器秒表功能
- C#完成DDA算法的实现
-
xm
l文件操作 C#源码
评论
共有 条评论