Windows Phone 7 的协议缓冲网络
我正在尝试从 Windows Phone 7 应用程序中的协议缓冲区格式的服务器下载响应。
我正在尝试使用 WebClient 来执行此操作,我的问题如下。
WebClient 只有两种下载方法
DownloadStringAsync(new Uri(url));
,
OpenReadAsync(new Uri(url));
但这两种方法不能很好地检索响应,因为响应大小应该有 16 个十六进制字符( 080118CBDDF0E104 ),但这两种方法获取的字符串和流的大小仅为8.
所以我正在寻找一种方法来解决我的问题。 我找到了一个 C#
public static T DownloadProto<T>(this WebClient client, string address)
{
byte[] data = client.DownloadData(address);
using (var ms = new MemoryStream(data))
{
return Serializer.Deserialize<T>(ms);
}
}
但该方法已被删除或尚未实现在 Windows Phone 7 开发套件上。
I'm trying to download a response from a server wich is in Protocol Buffer format from a Windows Phone 7 application.
I'm trying to do this with a WebClient, my problem is the following.
The WebClient has only two method for downloading
DownloadStringAsync(new Uri(url));
and
OpenReadAsync(new Uri(url));
but this two method are not good to retrieve the response because, the response size should have 16 hexadecimal caracteres ( 080118CBDDF0E104 ), but the size of the string and the stream get by the two methods are only 8.
So I'm searching a way to resolve my problem.
I found one for C#
public static T DownloadProto<T>(this WebClient client, string address)
{
byte[] data = client.DownloadData(address);
using (var ms = new MemoryStream(data))
{
return Serializer.Deserialize<T>(ms);
}
}
But this method was deleted or not yet implemented on the Windows Phone 7 development kit.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您如何从流中读取内容?
如果您将其作为字符串读取,那么它可能每个字符读取两个字节 - 相反使用
How are you reading from the stream?
If you are reading it as a string then its perhaps reading two bytes per character - instead use