Writing Mobile Code Essential Software Engineering for Building Mobile Applications [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Writing Mobile Code Essential Software Engineering for Building Mobile Applications [Electronic resources] - نسخه متنی

Ivo Salmre

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید











Pushing Information to a Device


The fact that much of mobile device communications centers on mobile devices initiating conversations with servers is not by accident. After a connection with a server is established, it is easy to push data up to a server or pull data down from a server. Most communication with servers uses abstractions such as sockets or HTTP, which are built on top of Internet TCP/IP protocols. In TCP/IP communications, each device on the network has its own IP address. An IP address is like a phone number, with the caveat that some IP addresses are permanent, some are long lived, and some are far more transient. An understanding of the transient nature of some IP addresses is important to understand which communications models are practical for mobile device applications and which are not.

Internet servers have IP addresses that rarely change. In addition, there exist mechanisms for looking up the IP address based on friendly URL names. The most popular Internet name lookup service is called DNS, which stands for Domain Naming System; it translates friendly names such as www.microsoft.com or www.yahoo.com to IP addresses. These DNS servers maintain replicated databases that map names to IP addresses. This works well because the server IP addresses rarely change.

Things work in a fairly similar way inside intranets. A server, desktop, or laptop name is registered and associated with an IP address. Sometimes these IP addresses are fixed, but usually internal IP addresses are loaned to computers by servers known as DHCP servers. DHCP stands for Dynamic Host Configuration Protocol, and as you might imagine the DHCP server's task is to loan out IP addresses to client computers who ask for them. Again the assumption is that these IP addresses do not change very often. A server that changed IP addresses very often would be a burden on the network because its address would require constant updating and lookup by client computers. Devices that appear and disappear on the network often because they are constantly roaming between different parts of the network or being turned on and off often will end up changing IP addresses frequently.

If a mobile device is going to be confined to a specific network topology (for example, inside a single corporate network), the addressing challenge for mobile devices is relatively straightforward. In these cases, one of two solutions is possible: (1) simply assigning the mobile device a fixed IP address, which is the simplest but least-flexible solution, or (2) building a custom mapping server that gets called by devices to register their IP address whenever they change; other devices can query this server for the address of a given device.

For devices that roam through different networks, the problem is far more complex. A static IP address is not permissible because it relies on the consent of the operating network, which may have already handed out or reserved any given IP address that the device may want to use. The presence of proxy servers, NATs (Network Address Translators), and firewalls present additional problems. Proxy servers, NATs, and firewalls allow specific kinds of outgoing requests and route responses back to the computing devices that made the requests; they do not generally allow unsolicited incoming requests to devices inside the networks. A device inside a network making server requests does not need to be aware of these complexities, but any party attempting to access a device from outside the network does.

The net result of all this is that for roaming mobile devices it is very difficult to send requests down to the devices; there is no good generic model for accomplishing this. This results in an asymmetry; it is far easier to make requests from a device than it is to send requests to a device.


But Won't IPv6 Solve All These Problems?


The answer is "maybe in the long run," but as the famous economist John Maynard Keynes stated, "Long run is a misleading guide to current affairs. In the long run we are all dead." It will take many years for IPv6 to fully filter out into the world, and in any case network security components such as firewalls are here to stay. The implication of this is that servers will remain easier to address than mobile devices. Mobile devices that travel constantly through different network topologies will require special mechanisms to address them.

In some cases, it is useful to be able to push information down to a mobile device. As noted previously, for custom static network topologies this is not a large problem; the mobile device can have a fixed or specially registered IP address and simply open up a socket and wait for requests to come in. For general-purpose mobile devices that roam through different networks, this is a challenge. The challenge can be addressed in several ways:

Mobile phones can use SMS message reception
Most mobile phones today support the widely popular SMS (Short Message Service) mechanism for pushing short streams of data down to devices. SMS offers a convenient universal addressing scheme: the device's phone number. Usually these SMS messages are text messages for the user to read, but this need not be the only use. Because SMS messages are limited to about 160 characters of information, a good model for using SMS to push information to a device is "push to pull"; a specific SMS message's arrival triggers a local application to access a server and download a larger amount of information.

E-mail messages
Many rich mobile devices support receiving e-mail notifications either to a phone-specific e-mail address or to the user's regular e-mail address. Sending specific messages to a device that are intended to be interpreted by a local application is a powerful way to push data down to a device.

Polling
Polling is simply occasionally making a call from the device to a server to see whether new information intended for the device is pending.


Of the three mechanisms described above, polling is the least sophisticated and by far the easiest to implement. Only in cases where a polling-based solution proves to be inadequate should other mechanisms be looked at.

Presently when developing with the .NET Compact Framework v1.1 there is no built-in library support for intercepting or viewing incoming e-mail or SMS messages; to do this, native code will have to be written and fairly sophisticated operations will need to be performed. Accessing incoming e-mail and SMS messages is not infeasible, but it is a significant amount of work. This work needs to be justified by proving that a less-elegant but simpler solution is not sufficient to meet your mobile application's needs. Writing low-level messaging code is interesting work, but is hardly ever a high-productivity task; weigh the alternatives and choose wisely.


Accessing Incoming SMS Messages on a Microsoft Smartphone


There are two ways for working with SMS messages on a Microsoft Smartphone: (1) working at a low level by building your own filter to inspect incoming messages, or (2) working at a high level using the "CE Messaging API" to look at messages after they have arrived. Both presently require C/C++ native code to access the necessary operating system functionality.

Building Your Own Low-Level SMS Filter for Incoming Messages

The Smartphone OS offers advanced developers two ways to register their own filters for handling SMS messages. This can be done by building and registering an on-device SMS provider or by building and registering a component that implements the IMailRuleClient interface.

In principle both of these approaches are similar to developing an ISAPI filter for Internet Information Server; multiple filters are can run simultaneously, and the first filter whose criteria matches incoming requests is given the request to handle. (For example, in ISAPI ,*.ASP Web page requests are routed to one handler, and *.ASPX Web page requests are routed to another based on the file extension.) Building ISAPI filters for Internet Information Server is a sophisticated feature demanding careful design and testing. Just as almost all Web developers do not require their own custom ISAPI filters, almost all mobile device developers do not require their own SMS provider or IMailRuleClient component. Nevertheless the flexibility is there if needed.

SMS Providers


SMS providers get to examine the headers of incoming SMS messages and decide what application to deliver them to. This is true for both binary and text SMS messages. However, as a practical matter, many "locked" Smartphones will not allow you to implement your own SMS provider because it may violate the security policy of the phone's issuer.Short Message Service" section of the "Smartphone Adaptation Kit for Mobile Operators" documentation.

IMailRuleClient


For Smartphone 2003 and later devices, it is possible to implement and register a component implementing the IMailRuleClient interface. This is a higher-level approach versus building an SMS provider and is preferable because it is intended for application developers as opposed to mobile network operators issuing the phones. IMailRuleClient allows a component to inspect incoming SMS messages and respond to them. This may be a more feasible approach than writing your own SMS provider but will still require the component to be signed with an authorized cryptographic key if the mobile phone's issuer demands this. More information on IMailRuleClient can be found by searching for IMailRuleClient or "CEMAPI" on MSDN online.


/ 159