简体   繁体   English

GetCallbackChannel()如何在双工wcf通道上工作?

[英]How does GetCallbackChannel() work on a duplex wcf channel?

When a service is working with a duplex binding in WCF, you can do this within an operation: 当服务在WCF中使用双工绑定时,您可以在操作中执行此操作:

OperationContext.Current.GetCallbackChannel<IClientReceiver>()

to get a reference to the caller. 获取对调用者的引用。 What is that reference? 那是什么参考? I mean, it looks like it's doing some voo-doo magic. 我的意思是,看起来它正在做一些voo-doo魔术。 What is happening behind the scenes that allows the service to send a message back to the client? 幕后发生了什么,允许服务将消息发送回客户端?

And how does this work differently on a TCP binding vs. duplex http binding? 如何在TCP绑定与双工http绑定上有所不同? Because I understand TCP can natively call back to the client, but http can't so it has to create a second channel on the server side to call down to the client. 因为我理解TCP本身可以回调客户端,但是http不能这样,所以它必须在服务器端创建第二个通道来调用客户端。

On the WSDualHttpBinding there are actually two HTTP connections: one from the client to the server, one from the server to the client. WSDualHttpBinding上实际上有两个HTTP连接:一个从客户端到服务器,一个从服务器到客户端。 GetCallbackChannel<T> will return a reference to a channel which knows how to send messages to the client, and, as you pointed out, is dependent on the underlying transport. GetCallbackChannel<T>将返回对知道如何向客户端发送消息的通道的引用,并且正如您所指出的,它依赖于底层传输。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM