资源简介
用c#语言编写的P2P聊天程序源代码
很经典的例子,
![](http://www.nz998.com/pic/37539.jpg)
代码片段和文件信息
// 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# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
- C#自定义控件
- 基于c#的实验室设备管理系统621530
- C# 使用ListView控件实现图片浏览器(源
- C#简单窗体聊天程序
- C#指纹识别系统程序 报告
- c# 高校档案信息管理系统
- c#向word文件插入图片
- C#左侧导航菜单(动态生成)
评论
共有 条评论