2012-02-10 58 views
2

我想使用苹果的APNS和c#服务。该服务运行完美。 我想要的是苹果的反馈,如果有平底锅发送给苹果。 所以我需要的是来自sslstream的反馈。APNS APPLE C#sslstream响应

任何人都可以帮助我,告诉我如何从sslstream服务器反馈?

在此先感谢

这里是我的代码如何发送STHE锅到苹果服务器:

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(); 

回答

0

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

如果你发送通知并且APN发现通知格式不正确 或以其他方式无法理解,则返回错误响应数据包之前的格式为 断开连接。 (如果没有错误,则APN不会返回 任何内容。)图5-3描述了错误响应 数据包的格式。

我假设你只是从流中读回,但我自己还没有得到这个工作。 我试图发送格式错误的请求来尝试重传数据包,但是我的读取呼叫被阻止,看似等待ANPS响应。

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。我相信这些事件可能是您正在搜索的反馈。