如何将数据推送到 .NET CF 客户端? [英] How to push data to a .NET CF client?

查看:39
本文介绍了如何将数据推送到 .NET CF 客户端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然可以轮询 Web 服务,但您知道除了使用交换服务器邮件传输之外的另一种将更改推送到移动客户端的方法吗?

Although polling a webservice is possible, do you know of another method to push changes to a mobile client except using the exchange server mail transport?

推荐答案

正如 Mark Seemann 所说:当我在 Microsoft Dynamics Mobile 团队时,我曾经为 .NET CF 做过客户端通知系统的 POC.

As Mark Seemann worte: I once did a POC of a client notification system for .NET CF when I was in the Microsoft Dynamics Mobile team.

当时我没有找到任何可以做到这一点的现成解决方案,我不想搭载 Exchange Server 连接,因为目标用户没有 AD 帐户,而且大多数肯定没有使用交换服务器.所以我和你现在的情况一样.我开始寻找可能的解决方案...

At the time I didn't find any Out-Of-The-Box solutions that could do this and I didn't want to piggyback on the Exchange Server connection since the intended users didn't have a AD account and most certanly didn't use the exchange server. So I was in the same situation as you are now. I started searching for possible solutions...

我意识到服务器无法连接到客户端,因为它的 IP 地址不断变化(从 3G 到 WiFi,断开连接等).客户端必须连接到服务器.此外,我发现大多数网络都允许 HTTP 连接,但并不总是允许通过自定义端口进行自定义 TCP 连接.

I realised that the server coudn't connect to the client since the IP address of this constantly changes (going from 3G to WiFi, loosing connection, etc). The clinent had to connect to the server. Furthermore I found that most networks allows HTTP connections but not always custom TCP connections over custom ports.

我使用Comet"来执行从客户端 (.NET CF) 到服务器 (IIS) 的长期 http 请求,并使用此连接将通知推送到客户端.如果客户端在收到通知之前超时,它只会发出一个新请求.

I used "Comet" to do long-held http requests from client (.NET CF) to server (IIS) and pushed the notifications to the client using this connection. If the client got a timeout before a notification was given it would simply make a new request.

在服务器端,我使用了 AsyncHttpHandler 和等待线程的组合,这些线程每秒检查发送到已连接客户端的消息.使用 AsyncHttpHandler 很重要,否则会阻塞 IIS 服务器.

On the serverside I used a combnation of an AsyncHttpHandler and wait threads that checked for messages to the connected clients every sec. It is important to use a AsyncHttpHandler or you'll block the IIS server.

POC 运行良好,事实证明它是一个可靠的解决方案.这样做有一些缺点:如果您不小心,您会很快耗尽电池电量.

The POC worked well and it proved to be a reliable solution. There are some drawbacks to this: if you are not careful you'll drain the battery quite quickly.

不幸的是,代码太多了,我无法在此处发布代码,但如果您愿意,欢迎与我联系,我会将我的 POC 通过电子邮件发送给您.

Unfortunately there are simply too many lines of code involved for me to post the code here, but if you like you are more that welcome to contact me and I'll e-mail you my POC.

这篇关于如何将数据推送到 .NET CF 客户端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆