j2meP2PClient.nEventService Class Reference

This class implements the end point of an Event based P2P connection. More...

Inherits j2meP2PClient::nService.


Public Member Functions

void close () throws IOException
 Closes the service and informs the remote service that it has been closed.
void deregisterListener (final nEventServiceListener listener) throws IOException
 Removes the registered nEventServiceListener from this service.
nOutOfBandService getOutOfBandService ()
 This function returns an nOutOfBandService.
nObject read (final long timeout) throws IOException
 Waits for a new nConsumeEvent to be received from the remote service or the timeout to be reached.
nObject read () throws IOException
 Waits for a new nConsumeEvent to be received from the remote service.
void registerListener (final nEventServiceListener listener) throws IOException
 Registers an nEventServiceListener with this class.
void write (final nObject evt) throws IOException
 Writes an nConsumeEvent to the remote P2P service.

Detailed Description

This class implements the end point of an Event based P2P connection.

It allows the user to send and receive nConsumeEvents.

See also:
nStreamService

Member Function Documentation

void j2meP2PClient.nEventService.close (  )  throws IOException

Closes the service and informs the remote service that it has been closed.

Exceptions:
IOException if unable to perform the close. See the message for further information

void j2meP2PClient.nEventService.deregisterListener ( final nEventServiceListener  listener  )  throws IOException

Removes the registered nEventServiceListener from this service.

When all listeners are removed then the read() method can then be called

Parameters:
listener An Instance of an nEventServiceListener that is to be removed
Exceptions:
IOException if Service is closed or listener is null

nOutOfBandService j2meP2PClient.nEventService.getOutOfBandService (  ) 

This function returns an nOutOfBandService.

An out of band (OOB) service can be used to pass flow/control information between the remote P2P service

Returns:
A new nOutOfBandService object

nObject j2meP2PClient.nEventService.read ( final long  timeout  )  throws IOException

Waits for a new nConsumeEvent to be received from the remote service or the timeout to be reached.

Parameters:
timeout The number of milliseconds to wait for an event to be received
Returns:
nConsumeEvent An event written by the remote service
Exceptions:
IOException if the lower streams have an error, See the message or more information

nObject j2meP2PClient.nEventService.read (  )  throws IOException

Waits for a new nConsumeEvent to be received from the remote service.

Returns:
nConsumeEvent An event written by the remote service
Exceptions:
IOException if the lower streams have an error, See the message or more information

void j2meP2PClient.nEventService.registerListener ( final nEventServiceListener  listener  )  throws IOException

Registers an nEventServiceListener with this class.

This nEventServiceListener will be called whenever there is a new event received

Once this is called then this will preclude the use of the read() method

Parameters:
listener An Instance of an nEventServiceListener that is to be used
Exceptions:
IOException if Service is closed or listener is null

void j2meP2PClient.nEventService.write ( final nObject  evt  )  throws IOException

Writes an nConsumeEvent to the remote P2P service.

Parameters:
evt An nConsumeEvent to send to the remote P2P service
Exceptions:
IOException if the lower streams have an error, See the message or more information