APNS APPLE C# sslstream response
本文关键字:response sslstream APPLE APNS | 更新日期: 2023-09-27 18:24:12
我想使用苹果公司的APNS和c#服务。服务运行完美。我想得到的是苹果公司的反馈,如果你把锅发给苹果公司的话。所以我需要的是来自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();
从这个苹果链接:http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingWIthAPS/CommunicatingWIthAPS.html
如果您发送通知,而APN发现通知格式不正确或者在其他方面无法理解,它在断开连接。(如果没有错误,APN不会返回任何东西。)图5-3描述了错误响应的格式小包裹
我想你只是从流中读了回来,但我自己还没有做到这一点。我试图发送格式错误的请求来响应数据包,但我的读取调用被阻止了,似乎在等待ANPS的响应。
我从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。我相信这些事件可能是您正在搜索的反馈。