• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

building a semi-connected application

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does anybody know a way to do something like this in J2ME:
Building a semi-connected application
 
author
Posts: 1436
6
Python TypeScript Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The whole point of J2ME is "occassionally connected" apps. Yes, that sort of auto-detecting network and switching between offline/online mode tasks are very easy in J2ME. To detect the network in J2ME, you just send a packet to a server, if it throws an exception, switch to the offline mode in your exception handling code.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should also take a look at the book Michael's sig is boasting. It provides a valuable resource of approaches to implementing such applications.
 
Henk Rog
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I will take a look at that book.
Are there any examples of that kind of applications on the internet?
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Smart Ticket blueprint might be a good start.
 
Henk Rog
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I understand how to switch from online mode to offline mode, but how can I automatically detect if the connection is available again?
(offline --> online)
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By trying?
For example, every 5 minutes try to first connect and then continue in the offline mode if the connection still fails.
 
Michael Yuan
author
Posts: 1436
6
Python TypeScript Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Lasse Koskela:
By trying?
For example, every 5 minutes try to first connect and then continue in the offline mode if the connection still fails.


This is exactly what that MSDN app does. It uses a timer thread to ping the server every 10 seconds. You can do exactly the same on J2ME using the Timer and TimerTask classes.
 
Henk Rog
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And how can I ping in J2ME? Or can I do something else instead of pinging?
[ December 05, 2003: Message edited by: Henk Rog ]
 
Michael Yuan
author
Posts: 1436
6
Python TypeScript Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Henk Rog:
And how can I ping in J2ME?


You post a byte of data to the server via HTTP and receive the response. If the MIDlet throws an exception in the process, the ping is failed and the Timer re-pings in several minutes.
If you do not want to ping, you can have the server push the data to you via SMS messages or even SIP. But that is a whole new programming paradigm.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic