Connection Method Using Direct TCPIP Instead of BESMDS

Now, let's take a few minutes to see how to force a connection to make a direct TCP/IP connection to the server instead of using the BES/MDS. The Networking application currently uses the device's default connection method. As mentioned earlier, if you run the application on a device that's not activated on a BES, the requests will already go over direct TCP/IP. However, if you run on a device connected to a BES, the POST and GET requests are done through the BES. To force them to go directly, we just have to add a BlackBerry-specific parameter to the end of the URL when we call Connector.open. The parameter we want is ;deviceside=true, so the URL for the web application becomes:

http://b eginningblackberry.appspot.com;deviceside=true

Modify the run method of HttpRequestDispatcher to add this automatically:

HttpConnection connection = (HttpConnection)Connector.open(url + ";deviceside=true");

We can actually test this on the simulator because it respects this parameter, too. If we specify deviceside=true, the simulator won't connect through the MDS simulator. So, uncheck the appropriate Launch Mobile Data System check box, ensure the MDS command window isn't open (if it is, just close it), and then run the application again. We'll be able to make connections without the MDS simulator running!

0 0

Post a comment

  • Receive news updates via email from this site