com.zion.jbuddy
Interface IGateway


public interface IGateway

Provides a callback mechanism for receiving messages and events the IM server. The IClient will invoke these methods from its listener thread as it receives events from the server.

It is important that your implementation of the callback methods are lightweight and return right away, in order for the client thread to continue processing events.


Field Summary
static String AUTH_REQUEST_MESSAGE
          Deprecated. As of 2.0, this constant is no longer used in the JBuddy SDK.
 
Method Summary
 void adminMessage(IClient client, IMessage message)
          Handles special notifications from the server (including errors).
 void connectionLost(IClient client, String reason)
          Indicates that the client's connection to the server has been lost, and its listener thread has been stopped.
 void incomingBuddy(IClient client, IBuddy buddy)
          Handles presence updates from the server.
 void incomingMessage(IClient client, IMessage message)
          Handles incoming messages.
 

Field Detail

AUTH_REQUEST_MESSAGE

static final String AUTH_REQUEST_MESSAGE
Deprecated. As of 2.0, this constant is no longer used in the JBuddy SDK.
This constant is no longer used in the JBuddy SDK and may be removed in a future release.

See Also:
IMessage.AUTH_REQUEST, Constant Field Values
Method Detail

adminMessage

void adminMessage(IClient client,
                  IMessage message)
                  throws Exception
Handles special notifications from the server (including errors). This may indicate errors that occur when negotiating a connection with the server.

Parameters:
client - the client that received the message
message - the message
Throws:
Exception

connectionLost

void connectionLost(IClient client,
                    String reason)
                    throws Exception
Indicates that the client's connection to the server has been lost, and its listener thread has been stopped.

Since JBuddy 5.1, the reason field has the form [reason type] - [description], where [reason type] is an IClient reason constant such as FAILED_LOGIN_REASON.

The following code illustrates how to handle failed login attempts.

    if (reason.startsWith(IClient.FAILED_LOGIN_REASON)) {
        String description = reason.substring(IClient.FAILED_LOGIN_REASON.length() + 3);
        System.out.println("Our login attempt failed because of " + description);
    }
 

Parameters:
client - the client whose connection has been lost
reason - a description of what caused the connection to be lost
Throws:
Exception
See Also:
IClient.CONNECTION_CLOSED_REASON, IClient.DISCONNECT_REASON, IClient.FAILED_LOGIN_REASON, IClient.NETWORK_ERROR_REASON, IClient.SERVICE_TEMPORARILY_UNAVAILABLE_REASON, IClient.USER_BOOTED_REASON, IClient.UNKNOWN_REASON

incomingBuddy

void incomingBuddy(IClient client,
                   IBuddy buddy)
                   throws Exception
Handles presence updates from the server.

Presence updates are only received for users in this client's Buddy List.

Parameters:
client - the client that received the presence update
buddy - the IBuddy instance, which holds the buddy's updated information
Throws:
Exception

incomingMessage

void incomingMessage(IClient client,
                     IMessage message)
                     throws Exception
Handles incoming messages.

Authorization request messages may also be received via this method. An authorization request occurs when another user has added the client to their Buddy List, thus requesting presence updates on the client. Add such users to the Permit List or Deny List when receiving authorization requests.

Parameters:
client - the client that received the message
message - the message
Throws:
Exception


JBuddy is a trademark of Zion Software, LLC in the US and other countries.
Copyright 2000-2012 Zion Software, LLC All Rights Reserved.