.NET Framework 3.5。在服务器端,我有一个接口
public interface IClientCallback
{
[OperationContract(IsOneWay = true)]
void ReceiveBroadcast(string nickname, string message);
[OperationContract(IsOneWay = true)]
void ReceivePrivate(string nickname, string message);
[OperationContract(IsOneWay = true)]
void UserJoined(string nickname);
[OperationContract(IsOneWay = true)]
void UserLeft(string nickname);
}
使用svcutil我已经生成了folliwing接口
public interface IServerCallback
{
[System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://tempuri.org/IServer/ReceiveBroadcast")]
void ReceiveBroadcast(string nickname, string message);
[System.ServiceModel.OperationContractAttribute(IsOneWay=true, AsyncPattern=true, Action="http://tempuri.org/IServer/ReceiveBroadcast")]
System.IAsyncResult BeginReceiveBroadcast(string nickname, string message, System.AsyncCallback callback, object asyncState);
void EndReceiveBroadcast(System.IAsyncResult result);
[System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://tempuri.org/IServer/ReceivePrivate")]
void ReceivePrivate(string nickname, string message);
[System.ServiceModel.OperationContractAttribute(IsOneWay=true, AsyncPattern=true, Action="http://tempuri.org/IServer/ReceivePrivate")]
System.IAsyncResult BeginReceivePrivate(string nickname, string message, System.AsyncCallback callback, object asyncState);
void EndReceivePrivate(System.IAsyncResult result);
[System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://tempuri.org/IServer/UserJoined")]
void UserJoined(string nickname);
[System.ServiceModel.OperationContractAttribute(IsOneWay=true, AsyncPattern=true, Action="http://tempuri.org/IServer/UserJoined")]
System.IAsyncResult BeginUserJoined(string nickname, System.AsyncCallback callback, object asyncState);
void EndUserJoined(System.IAsyncResult result);
[System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://tempuri.org/IServer/UserLeft")]
void UserLeft(string nickname);
[System.ServiceModel.OperationContractAttribute(IsOneWay=true, AsyncPattern=true, Action="http://tempuri.org/IServer/UserLeft")]
System.IAsyncResult BeginUserLeft(string nickname, System.AsyncCallback callback, object asyncState);
void EndUserLeft(System.IAsyncResult result);
}
如您所见,它提供了End *和Begin *方法,尽管所有操作都是单向的。可能是什么原因?我尝试将AsyncPattern = false添加到IClientCallback方法,但没有结果。