public boolean register(String user, String password, String contact, int expiry, long timeout) {
    AddressFactory addrFactory = parent.getAddressFactory();
    SipURI requestUri = null;

    try {
      if (proxyHost != null) {
        requestUri = addrFactory.createSipURI(null, proxyHost);
        requestUri.setPort(proxyPort);
        requestUri.setTransportParam(proxyProto);
      }

      return register(requestUri, user, password, contact, expiry, timeout);
    } catch (Exception ex) {
      setReturnCode(EXCEPTION_ENCOUNTERED);
      setException(ex);
      setErrorMessage("Exception: " + ex.getClass().getName() + ": " + ex.getMessage());
      return false;
    }
  }
public boolean register ( String user , String password , String contact , int expiry , long timeout ) { AddressFactory addrFactory = parent . getAddressFactory ( ) ; SipURI requestUri = null ; try { if ( proxyHost != null ) { requestUri = addrFactory . createSipURI ( null , proxyHost ) ; requestUri . setPort ( proxyPort ) ; requestUri . setTransportParam ( proxyProto ) ; } return register ( requestUri , user , password , contact , expiry , timeout ) ; } catch ( Exception ex ) { setReturnCode ( EXCEPTION_ENCOUNTERED ) ; setException ( ex ) ; setErrorMessage ( "Exception: " + ex . getClass ( ) . getName ( ) + ": " + ex . getMessage ( ) ) ; return false ; } }
This method is used for SIP registration. By default, the Request-URI is derived from this
SipPhone's proxy host, or if no proxy was specified when this SipPhone was created, the
Request-URI address information is taken from this SipPhone's URI (address of record). For
other Request-URI alternatives, see the register() method that takes parameter requestUri.

<p>
Initially, a REGISTER message is sent without any user name and password. If the server returns
an OK, this method returns a true value.

<p>
If any challenge is received in response to sending the REGISTER message (response code
UNAUTHORIZED or PROXY_AUTHENTICATION_REQUIRED), the SipPhone's credentials list is checked
first for the corresponding realm entry. If found, the credentials list entry username and
password are used to form the required authorization header for resending the REGISTER message
to the server, and the authorization header is saved for later re-use. You can clear out saved
authorization headers by calling the unregister() method.

<p>
If the challenging realm is not found in the SipPhone credentials list, the user parameter
passed to this method is examined. If it is null, this method returns false. If it is not null,
the user and password values passed in to this method are used to respond to the challenge. The
credentials list is not modified by this scenario (no entry is automatically added with this
user, password). Also, the authorization created for this registration is not saved for re-use
on a later registration. IE, the user/password parameters are for a one-time, single-shot use
only.

<p>
After responding to the challenge(s) by resending the REGISTER message, this method returns a
true or false value depending on the outcome as indicated by the server.

<p>
If the contact parameter is null, user@hostname is used where hostname is the SipStack's IP
address property which defaults to InetAddress.getLocalHost().getHostAddress(), and other
SipStack properties also apply. Otherwise, the contact parameter given is used in the
Registration message sent to the server.

<p>
If the expiry parameter is 0, the registration request never expires. Otherwise, the duration,
given in seconds, is sent to server.

<p>
This method can be called repeatedly to update the expiry or to add new contacts.

<p>
This method determines the contact information for this user agent, whether the registration
was successful or not. If successful, the contact information may have been updated by the
server (such as the expiry time, if not specified to this method by the caller). Once this
method has been called, the test program can get information about the contact for this agent
by calling the *MyContact*() getter methods.

@param user Optional - user name for authenticating with the server. Required if the server
issues an authentication challenge.
@param password Optional - used only if the server issues an authentication challenge.
@param contact An URI string (ex: sip:bob@192.0.2.4), or null to use the default contact for
this user agent.
@param expiry Expiry time in seconds, or 0 if no registration expiry.
@param timeout The maximum amount of time to wait for a response, in milliseconds. Use a value
of 0 to wait indefinitely.
@return false if registration fails or an error is encountered, true otherwise. In case of
false, call getErrorMessage(), getReturnCode() and/or getException() methods to find
out why.