110,567
社区成员
发帖
与我相关
我的任务
分享
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="webbehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<services>
<service behaviorConfiguration="webbehavior" name="nt.web.WCF.User">
<host>
<baseAddresses>
<add baseAddress="http://192.168.0.212:1912/WCF/"/>
</baseAddresses>
</host>
<endpoint binding="basicHttpBinding" contract="nt.WcfContract.IUser" name="user_contract" address="User.svc"></endpoint>
</service>
<service behaviorConfiguration="webbehavior" name="nt.web.WCF.Communication">
<host>
<baseAddresses>
<add baseAddress="http://192.168.0.212:1912/WCF/"/>
</baseAddresses>
</host>
<endpoint binding="wsDualHttpBinding" contract="nt.WcfContract.ICommunicationContract" name="user_communication" address="Communication.svc"></endpoint>
</service>
</services>
</system.serviceModel>
[ServiceContract(CallbackContract = typeof(IServerCallback))]
public interface ICommunicationContract
{
[OperationContract(IsOneWay = true)]
void HeartBeat(Model_User user);
[OperationContract(IsOneWay = true)]
void LoginOut();
}
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, ConfigurationName = "user_communication")]
public class Communication : ICommunicationContract
{
public void HeartBeat(WCFModel.Model_User user)
{
//Logic_DesktopUser.UserHeartBeat(user);
}
public void LoginOut()
{
//Logic_DesktopUser.LoginOut(user);
var callback = OperationContext.Current.GetCallbackChannel<nt.WcfContract.IServerCallback>();
callback.CallBack();
}
}
DuplexChannelFactory<nt.WcfContract.ICommunicationContract> duplex = new DuplexChannelFactory<ICommunicationContract>(new InstanceContext(new ServerCallback()), "user_communication");
var bll = duplex.CreateChannel();
bll.LoginOut();