|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectAbstractSnacProcessor
ClientSnacProcessor
A client-side SNAC processor. In addition to the functionality provided by
AbstractSnacProcessor
, a ClientSnacProcessor
provides a
request-response system (see SnacRequest
, sendSnac
)
with automatic request ID generation and management.
ClientSnacProcessor
passes two additional (see AbstractSnacProcessor
) types of exceptions thrown during SNAC processing to
its attached FlapProcessor
's error handlers using
FlapProcessor
's handleException
method, which
in turn causes the exceptions to be passed to your own error handlers. The
extra error types used are ERRTYPE_SNAC_REQUEST_LISTENER
and ERRTYPE_SNAC_RESPONSE_LISTENER
. See individual documentation for each for
further detail.
A ClientSnacProcessor
intercepts incoming SNAC packets if they
match the request ID of a previous outgoing request (see below for details).
The process is as follows:
If the request ID matches that of a previous outgoing request,
SnacRequest
) SnacRequest
for more information on how to utilize the request
system.
ClientSnacProcessor
logs to the Java Logging API namespace
"net.kano.joscar.snac"
on the levels Level.FINE
and Level.FINER
in order to, hopefully, ease the debugging
SNAC-related applications. For information on how to access these logs,
see the Java Logging API reference at the J2SE website.
Field Summary | |
static java.lang.Object |
ERRTYPE_SNAC_REQUEST_LISTENER
An error type indicating that an exception was thrown while calling a SNAC request response listener to handle a response to a SNAC request or another request-related event. |
static java.lang.Object |
ERRTYPE_SNAC_RESPONSE_LISTENER
An error type indicating that an exception was thrown while calling a global SNAC response listener to handle a response to a SNAC request. |
static long |
REQID_MAX
The maximum request ID value before it wraps to REQID_MIN . |
static long |
REQID_MIN
The minimum request ID value. |
static int |
REQUEST_TTL_DEFAULT
The default SNAC request "time to live," in seconds. |
Fields inherited from class AbstractSnacProcessor |
ERRTYPE_SNAC_PACKET_LISTENER, ERRTYPE_SNAC_PACKET_PREPROCESSOR |
Constructor Summary | |
ClientSnacProcessor(FlapProcessor processor)
Creates a SNAC processor with no SNAC factories installed and the default request time-to-live, attached to the given FLAP processor. |
Method Summary | |
void |
addGlobalRequestListener(OutgoingSnacRequestListener l)
Adds a global request listener to listen for outgoing SNAC requests sent on this connection. |
void |
addGlobalResponseListener(SnacResponseListener l)
Adds a "global response listener" to listen for incoming SNAC request responses. |
protected boolean |
continueHandling(SnacPacketEvent event)
Returns whether or not the given SNAC packet event should be passed to packet listeners. |
void |
detach()
Detaches from the currently attached FLAP processor, if any. |
int |
getRequestTtl()
Returns the current "time to live" for SNAC requests, in seconds. |
SnacQueueManager |
getSnacQueueManager()
Returns this SNAC processor's current SNAC queue manager. |
boolean |
isPaused()
Returns whether this SNAC processor is currently paused. |
void |
migrate(FlapProcessor processor)
Attaches to the given FLAP processor without clearing any SNAC queues. |
void |
pause()
Pauses this SNAC processor. |
void |
removeGlobalRequestListener(OutgoingSnacRequestListener l)
Removes a global request listener from the list of listeners. |
void |
removeGlobalResponseListener(SnacResponseListener l)
Removes a "global response listener" from the list of listeners. |
void |
sendSnac(SnacRequest request)
Sends the given SnacRequest to the attached FLAP connection.
|
void |
sendSnacImmediately(SnacRequest request)
Sends the given SNAC request to the server, bypassing the SNAC request queue and any pausing status that may be present. |
void |
setRequestTtl(int requestTtl)
Sets the "time to live" for SNAC requests, in seconds. |
void |
setSnacQueueManager(SnacQueueManager mgr)
Sets this SNAC processor's SNAC queue manager. |
void |
unpause()
Unpauses this SNAC processor if previously paused with a call to pause() . |
void |
unsetSnacQueueManager(SnacQueueManager mgr)
Calls setSnacQueueManager(null) if and only
if the given mgr is the current SNAC queue manager. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.Object ERRTYPE_SNAC_REQUEST_LISTENER
getReason()
) will be
the SnacRequest
whose listener threw the exception.
public static final java.lang.Object ERRTYPE_SNAC_RESPONSE_LISTENER
getReason()
) will be
the SnacResponseListener
that threw the exception.
public static final int REQUEST_TTL_DEFAULT
setRequestTtl(int)
,
Constant Field Valuespublic static final long REQID_MIN
public static final long REQID_MAX
REQID_MIN
.
Constructor Detail |
public ClientSnacProcessor(FlapProcessor processor)
processor
- the FLAP processor to attach toMethod Detail |
public final void pause()
unpause()
. Note that
if this method is called while the processor is already paused, no action
will be taken. Note that SNAC commands can still be sent while the processor is paused; however, they will not be sent to
the server until unpausing.
unpause()
,
isPaused()
,
PauseCmd
public final void unpause()
pause()
. SNAC commands sent during the paused period will begin to be
sent to the server (depending on the implementation of the queue manager).
pause()
,
isPaused()
,
ResumeCmd
public final boolean isPaused()
pause()
public final void migrate(FlapProcessor processor)
migrate
will not unpause it. Unpausing must
be done explicitly with a call to unpause()
.
migrate
in class AbstractSnacProcessor
processor
- a new FLAP processor to use for this SNAC connectionMigrationNotice
public final void addGlobalRequestListener(OutgoingSnacRequestListener l)
l
- the listener to addpublic final void removeGlobalRequestListener(OutgoingSnacRequestListener l)
l
- the listener to removepublic final void addGlobalResponseListener(SnacResponseListener l)
l
- the listener to addpublic final void removeGlobalResponseListener(SnacResponseListener l)
l
- the listener to removepublic final void setSnacQueueManager(SnacQueueManager mgr)
mgr
is null
,
as is the default value, all SNACs will be sent to the server immediately
(the queue manager will be set to an ImmediateSnacQueueManager
)
mgr
- the new SNAC queue manager, or null
to send all
SNACs immediatelypublic final void unsetSnacQueueManager(SnacQueueManager mgr)
setSnacQueueManager(null)
if and only
if the given mgr
is the current SNAC queue manager. If the
given SNAC queue manager is not the current SNAC queue manager, no change
takes place.
mgr
- the SNAC queue manager to unset, if setpublic final SnacQueueManager getSnacQueueManager()
null
, even after an explicit
call to setSnacQueueManager(null)
. See that
method's documentation for details.
public void setRequestTtl(int requestTtl)
SnacPacket
s and not responses to requests.
requestTtl
- the new "time to live" for SNAC requests, in secondspublic int getRequestTtl()
public final void sendSnac(SnacRequest request)
SnacRequest
to the attached FLAP connection.
It may not immediately be sent in future releases due to possible
features such as rate limiting prevention.
request
- the SNAC request to sendpublic final void sendSnacImmediately(SnacRequest request)
request
- the request to sendsetSnacQueueManager(net.kano.joscar.snac.SnacQueueManager)
public final void detach()
detach
in class AbstractSnacProcessor
migrate(net.kano.joscar.flap.FlapProcessor)
protected final boolean continueHandling(SnacPacketEvent event)
AbstractSnacProcessor
true
.)
continueHandling
in class AbstractSnacProcessor
event
- the event
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |