WaitForReconnect Method

This member of Class WaveLinkIO requires a Wavelink Studio 4.x or newer Client.

The WaitForReconnect Method determines if the application connection has been restored within a specified number of seconds after a WaveLinkError occurs.

Syntax

public boolean WaitForReconnect(int seconds)

Returns

A boolean true or false value that describes whether the device has successfully re-connected to the Wavelink application

Parameters

seconds

The amount of time to wait for the device to reconnect before returning false. The seconds begin counting down from the time that the broken connection is detected

Remarks

A WaveLinkError occurs when the connection to the mobile device is broken. Wavelink applications typically clean up any resources and exit after this type of communication failure. The WaitForReconnect Method is an alternative way to handle a WaveLinkError. WaitForReconnect suspends the Wavelink application until the device can re-establish a connection.

WaitForReconnect works by sending a cookie to the mobile device. This cookie is included in the connect process and used to re-connect a device to an active Wavelink application.

Special design considerations must be kept in mind for applications that use WaitForReconnect; it is not a transparent function. Care must be taken to ensure that the appropriate screen is redisplayed after a successful reconnect.

Example

package reconnect;

import com.wavelink.clientui.*;

public class Reconnect extends WaveLinkApplication {

private static int CLR = 27;

public void WaveLinkMain( String arg[] ) {

WaveLinkIO ioIface = new WaveLinkIO();

WaveLinkSignon signonObj;

try {

// The constructor parameter turns encryption on or off.

signonObj = new WaveLinkSignon( true );

} catch ( WaveLinkError e ) {

// failed initializing Signon Object

// exit the WaveLinkApplication

return;

}

// set the text of the WaveLinkSignon cancel button

signonObj.CancelButton().setDisplayText("Quit");

int loginFailureCounter = 1;

int exitCode;

boolean loggedIn = false;

// loop until the user logs in or presses cancel

do {

try {

// Defined exitCodes are CANCEL and NORMAL.

exitCode = signonObj.DisplayDialog();

} catch ( WaveLinkError e ) {

try {

// Redisplay the signonObj if a terminal successfully reconnects after a communication failure.

if ( ioIface.WaitForReconnect( 60 ) )

continue;

} catch ( Exception err ) {

}

// A terminal did not reconnect to this WaveLink application. Exit the WaveLinkApplication

return;

}

// Check to see if CANCEL was selected.

if ( exitCode == WaveLinkSignon.CANCEL )

return;

// Check to see if Login was selected.

if ( exitCode == signonObj.NORMAL ) {

// retrieve the userName and Password

String userName = signonObj.getUserName();

String password = signonObj.getPassword();

// compare to the valid userName and Password

if ( userName != null && password != null

&& userName.equalsIgnoreCase("a")

&& password.equalsIgnoreCase( "a") ) {

loggedIn = true;

} else {

signonObj.FeedbackLabel().setDisplayText( "Login Incorrect " ) );

 

// end of WaveLinkApplication

}

}

 


Was this article useful?    

The topic was:

Inaccurate

Incomplete

Not what I expected

Other

Privacy and Legal