Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 02:11, 4 July 2008.

Message handling in Java Platfrom, Micro Edition (Java ME)

From Forum Nokia Wiki

Introduction

Sending and receiving messages are carried out by the messaging API, JSR 120. The messaging API is based on the Generic Connection Framework (GCF), which is defined in the Connected Limited Device Configuration (CLDC) 1.0 specification. The package javax.microedition.io defines the framework and supports input/output and networking functionality in J2ME profiles. It provides a coherent way to access and organize data in a resource-constrained environment.

Code Sample 1 – A simplified version of the message handling classes

class MessageListenerImpl implements MessageListener
{
	public void notifyIncomingMessage(MessageConnection mCon)
	{ 
		messageReader.handleMessage(); 
	}
}
 
class WirelessMessageReader implements Runnable
{
 
	private boolean readMessages = true;
 
	private int pendingMessages;
 
	private MessageConnection msgConn = null;
 
 
	public void run()
	{
		while(readMessages)
		{
			synchronized(this)
			{
				if(pendingMessages == 0)
				{
					try
					{ 
						wait(); 
					}
					catch(InterruptedException ie) {}
				}
				pendingMessages--;
			}
			Message message = null;
			try
			{
				Message message = msgConn.receive();
				/* parse payload */
			}
			catch(IOException ioe) {}
		}
	}
 
	synchronized void handleMessage()
	{
		pendingMessages++;
		notify();
	}
}
Related Discussions
Thread Thread Starter Forum Replies Last Post
7210 Newbie isaacinsoll Mobile Java General 2 2002-12-30 09:41
create a forward lock on the fly with java twoandtwo Digital Rights Management & Content Downloading 6 2006-10-30 12:50
AT commands in Java nuaimat General Messaging 3 2006-03-21 07:44
Connect to agent error glaubertadeu Mobile Java Tools & SDKs 4 2008-05-31 22:04
Which version of Java? Poldie Mobile Java General 7 2006-03-14 10:52
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtopicQUqfnTopicZjavaQ
     qfnZtopicQUqfnTopicZmessagingQ
     qfnZtopicQUqfnTopicZsmsQ
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX