2

我想将 Apple 的 APNS 与 ac# 服务一起使用。服务运行完美。我想要的是来自 Apple 的反馈,如果已将平底锅发送到 Apple。所以我需要的是来自 sslstream 的反馈。

谁能帮助我并告诉我如何从 sslstream 中的服务器获得反馈?

提前致谢

这是我如何将平底锅发送到苹果服务器的代码:

    TcpClient client = new TcpClient(hostname, APNS_PORT);
    SslStream sslStream = new SslStream(
        client.GetStream(),
        false,
        new RemoteCertificateValidationCallback(ValidateServerCertificate),
        null
        );

     sslStream.AuthenticateAsClient(hostname, certificatesCollection, SslProtocols.Tls, true);

     sslStream.Write(array);
     sslStream.Flush();
4

2 回答 2

0

我从APNS Sharp获得了这些代码。

        if (!this.apnsStream.IsMutuallyAuthenticated)
        {
            if (this.Error != null)
            {
                this.Error(this, new NotificationException(4, "Ssl Stream Failed to Authenticate"));
            }
        }

        if (!this.apnsStream.CanWrite)
        {
            if (this.Error != null)
            {
                this.Error(this, new NotificationException(5, "Ssl Stream is not Writable"));
            }
        }

apnsStream就像你一样sslStream。我相信这些事件可能是您正在搜索的反馈。

于 2012-05-25T05:25:47.303 回答
0

从这个苹果链接:http: //developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingWIthAPS/CommunicatingWIthAPS.html

如果您发送通知并且 APNs 发现通知格式错误或无法理解,它会在断开连接之前返回错误响应数据包。(如果没有错误,APNs 不会返回任何内容。) 图 5-3 描述了错误响应数据包的格式。

我假设您只是从流中读回,但是我自己还没有完成这项工作。我尝试发送格式错误的请求以响应数据包,但是我的读取调用被阻止,似乎在等待 ANPS 响应。

于 2012-05-25T03:50:30.073 回答