I have a duplex channel that uses callbacks to provide updates as part of a subscription to some data (see below for interfaces). Occasionally that data is unavailable and when it is the server needs to shut down its subscription and let the client open a new one, so I want to notify the client that it needs to do so.
- What is the correct way to do so?
- Is it possible to pass back a
FaultException
via the IUpdate interface? It seems that thethrow new FaultException(...);
syntax is specific to request-response. - Do I need return a custom fault somehow?
- Do I just have to add a new
OnError
function or similar that explicitly forces the client to reconnect?
.
[ServiceContract(Namespace = "http://tempura.org/ISubscribe", Name = "ISubscribe", ConfigurationName = "Subscribe", CallbackContract = typeof(IUpdate))]
interface ISubscribe
{
[OperationContract]
long Subscribe();
[OperationContract(IsOneWay = true)]
void Unsubscribe(long index);
}
[ServiceContract(Namespace = "http://tempura.org/ISubscribe")]
public interface IUpdate
{
[OperationContract(IsOneWay = true)]
void OnUpdate(string update);
}