wpc 双工
在控制台部署wcf双工 这个可以被silverlight 使用
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="netTcpBindConfig">
<security mode="None"/>
</binding>
</netTcpBinding>
</bindings>
<services>
<service behaviorConfiguration="WCFLibrary.UpdateUserBehavior" name="WcfService1.Service1">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:4503/Service1"/>
</baseAddresses>
</host>
<endpoint address="" binding="netTcpBinding" contract="WcfService1.IService1" bindingConfiguration="netTcpBindConfig"></endpoint>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" ></endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WCFLibrary.UpdateUserBehavior">
<serviceMetadata/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
这个貌似不能被silverlight使用
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
</system.web>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="tcpBindingConfig1">
<security mode="None"/>
</binding>
</netTcpBinding>
</bindings>
<services>
<service name="WcfService1.Service1">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="tcpBindingConfig1" contract="WcfService1.IService1"/>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress = "http://localhost:9999/WcfStudy3/Service1" />
<add baseAddress = "net.tcp://localhost:8888/WcfStudy3/Service1" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="False"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="False" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
这个可以部署在IIS中 也是双工 这是wcf的配置文件
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
</system.web>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="tcpBindingConfig1">
<security mode="None"/>
</binding>
</netTcpBinding>
</bindings>
<services>
<service name="WcfService1.Service1">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="tcpBindingConfig1" contract="WcfService1.IService1"/>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:4502/Service1.svc"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="False"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="False" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
这是wcf程序
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
namespace WcfService1
{
// 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码和配置文件中的接口名“IService1”。
[ServiceContract(CallbackContract = typeof(iMyclass))]
public interface IService1
{
[OperationContract]
string Send(string id,string pid, string str);
[OperationContract]
string Register(string id);
[OperationContract]
List<string> ALLhost();
}
[ServiceContract]
public interface iMyclass
{
[OperationContract(IsOneWay = true)]//回调函数方法必须加IsOneWay=true
void Reciver(string str);
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
namespace WcfService1
{
// 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码、svc 和配置文件中的类名“Service1”。
public class Service1 : IService1
{
public static Dictionary<string, iMyclass> hostdic;
public static List<string> allhost;
/// <summary>
///
/// </summary>
/// <param name="id">发送人</param>
/// <param name="pid">接受人</param>
/// <param name="str">内容</param>
/// <returns></returns>
public string Send(string id,string pid, string str)
{
try
{
foreach (var d in hostdic)
{
if (d.Key == pid)
{
d.Value.Reciver(id+"发送:"+str);
}
}
//iMyclass myclass= OperationContext.Current.GetCallbackChannel<iMyclass>();
//myclass.Reciver("你好");
return "1";
}
catch (Exception ex)
{
return ex.Message;
}
}
public List<string> ALLhost()
{
return allhost;
}
public string Register(string id)
{
if (hostdic == null)
{
hostdic = new Dictionary<string, iMyclass>();
}
if (allhost == null)
{
allhost = new List<string>();
}
iMyclass imyclass = OperationContext.Current.GetCallbackChannel<iMyclass>();
hostdic.Add(id, imyclass);
allhost.Add(id);
return id;
}
}
}
wpc 双工的更多相关文章
- WCF学习之旅—TCP双工模式(二十一)
WCF学习之旅—请求与答复模式和单向模式(十九) WCF学习之旅—HTTP双工模式(二十) 五.TCP双工模式 上一篇文章中我们学习了HTTP的双工模式,我们今天就学习一下TCP的双工模式. 在一个基 ...
- WCF学习之旅—HTTP双工模式(二十)
WCF学习之旅—请求与答复模式和单向模式(十九) 四.HTTP双工模式 双工模式建立在上文所实现的两种模式的基础之上,实现客户端与服务端相互调用:前面介绍的两种方法只是在客户端调用服务端的方法,然后服 ...
- 利用WCF的双工通讯实现一个简单的心跳监控系统
何为心跳监控系统? 故名思义,就是监控某个或某些个程序的运行状态,就好比医院里面的心跳监视仪一样,能够随时显示病人的心跳情况. 心跳监控的目的是什么? 与医院里面的心跳监视仪目的类似,监控程序运行状态 ...
- 利用WCF双工模式实现即时通讯
概述 WCF陆陆续续也用过多次,但每次都是浅尝辄止,以将够解决问题为王道,这几天稍闲,特寻了些资料看,昨晚尝试使用WCF的双工模式实现了一个简单的即时通讯程序,通过服务端转发实现客户端之间的通讯.这只 ...
- [SignalR]SignalR与WCF双工模式结合实现服务端数据直推浏览器端
原文:[SignalR]SignalR与WCF双工模式结合实现服务端数据直推浏览器端 之前开发基于WinForm监控的软件,服务端基于Wcf实现,里面涉及双工模式,在客户端里面,采用心跳包机制保持与服 ...
- WCF服务创建与使用(双工模式)
昨天发布了<WCF服务创建与使用(请求应答模式)>,今天继续学习与强化在双工模式下WCF服务创建与使用,步骤与代码如下. 第一步,定义服务契约(Service Contract),注意Se ...
- WCF双工通讯以及客户端间的间接通讯
由于学习计划安排不当,对WCF的认知一直停滞不前,最近工作上又用回了WCF,重拾一下,看到蒋老师介绍双工通讯的博文,实践一下,积累一下.原想着WCF的双工通讯就是原本的客户端能调用服务端的方法之余,服 ...
- 浅谈WCF的三种通信模式:请求响应模式、数据报模式和双工通讯模式
一: WCF的服务端与客户端在通信时有三种模式:请求响应模式.数据报模式和双工通讯模式. 说一下基本知识, 1.如果想要将当前接口作为wcf服务器,则一定要加上[ServiceContract] 契 ...
- Wcf 双工通信的应用
概述 双工(Duplex)模式的消息交换方式体现在消息交换过程中,参与的双方均可以向对方发送消息.基于双工MEP消息交换可以看成是多个基本模式下(比如请求-回复模式和单项模式)消息交换的组合.双工ME ...
随机推荐
- 给kali linux2.0装一个中文输入法
没有中文输入法好痛苦啊.. 毕竟做了无限网卡,虚拟机和主机可以完完全全当两台设备使用了,所以kali还是需要一个中文输入法才方便. 由于使用的是比较新的kali版本和源,现在安装fcitx已经可以直接 ...
- 理解 Delphi 的类(十) - 深入方法[18] - 在接口区声明的方法都相当于提前声明了
//要点18: 如果函数在接口区定义了, 就无需用 forward 提前声明了 unit Unit1; interface uses Windows, Messages, SysUtils, Va ...
- 最小费用最大流spfa
#include <iostream> #include <cstring> #include <cstdio> #include <queue> #d ...
- mysql case when 判断null
select name,case WHEN m.NAME is null THEN '' else m.NAME end NAME1 from sys_users
- MT【242】图像几何意义
设函数$f(x)=x^2+ax+b$,已知函数$f(x)$在$[-1,1]$上存在零点,若$0\le b-2a\le 1$,求$b$的范围 (2015浙江文科高考20(2)) 分析:理解成$g(x)= ...
- Linux Install geoip
安装方法 http://php.net/manual/en/geoip.installation.phpgeoip中的PHP函数介绍:http://php.net/manual/en/book.geo ...
- linux一次性解压多个.gz或者.tar.gz文件
对于解压多个.gz文件的,用此命令: for gz in *.gz; do gunzip $gz; done 对于解压多个.tar.gz文件的,用下面命令: for tar in *.tar.gz; ...
- Best Time to Buy and Sell Stock - LeetCode
目录 题目链接 注意点 解法 小结 题目链接 Best Time to Buy and Sell Stock - LeetCode 注意点 在卖出之前必须要先购入 解法 解法一:遍历一遍,随时记录当前 ...
- POJ 1459 Power Network / HIT 1228 Power Network / UVAlive 2760 Power Network / ZOJ 1734 Power Network / FZU 1161 (网络流,最大流)
POJ 1459 Power Network / HIT 1228 Power Network / UVAlive 2760 Power Network / ZOJ 1734 Power Networ ...
- 【洛谷P1091】合唱队列
题目大意:给定一个有 N 个正整数的序列,从其中拿走一些数,使得剩下的数满足严格单峰性,即先严格递增后严格递减,允许单调增和单调减,求最少需要拿走多少数. 题解:先考虑严格单调的情况,最少需要拿走多少 ...