0

.NET 框架 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 我生成了以下界面

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 方法,但没有结果。

4

0 回答 0