|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectAbstractSnacProcessor
Provides an easy interface to listening for incoming SNAC packets as well as
sending SNAC commands over a FLAP connection. An
AbstractSnacProcessor
provides a system for "preprocessing"
SNAC's before they are formally handled and processed and a system for
listening for incoming packets (and optionally "vetoing" their further
processing).
AbstractSnacProcessor
passes two 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 error types used are ERRTYPE_SNAC_PACKET_PREPROCESSOR
and ERRTYPE_SNAC_PACKET_LISTENER
. See individual documentation for
each for further detail.
It may also be of interest to note that AbstractSnacProcessor
attaches a vetoable packet listener to any attached
FlapProcessor
, effectively removing any incoming SNAC packet
from the FlapProcessor's event queue. In practice this means that if you
attach a SNAC processor to a FlapProcessor
on which you are
listening for FLAP packets, your packet listener will not be called when a
channel-2 packet (SNAC packet) is received on that
FlapProcessor
. Instead, it will be processed as a
SnacPacket
and passed to any listeners on the SNAC processor.
Upon receipt of a SNAC packet, the packet is processed in the following
order:
SnacCommand
is generated (see below) ClientSnacProcessor
or
ServerSnacProcessor
; see the subclasses' documentation for
details SnacPacketListener
) packet listeners.SnacCommand
from a SnacPacket
is as such:
SnacCmdFactory
must be found
registerSnacFactory(new CmdType(family),
factory)
, for example), that factory is used registerSnacFactory(CmdType.CMDTYPE_ALL, factory)
, for example),
then that factory is used null
, the above three steps are repeated for the factories
registered by the default factory list SnacCommand
is generated
with a call to the factory's genSnacCommand
method SnacCommand
s passed
to your packet listeners, in order to, for example, process an extra field
in a certain command that has been added to the protocol since this library's
release. This can be done by registering your own SNAC command factories
with the appropriate command types (see CmdFactoryMgr
and getCmdFactoryMgr
).
AbstractSnacProcessor
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_PACKET_LISTENER
An error type indicating that an exception was thrown while calling a registered SNAC packet listener or vetoable packet listener to handle an incoming SNAC packet. |
static java.lang.Object |
ERRTYPE_SNAC_PACKET_PREPROCESSOR
An error type indicating that an exception was thrown while calling a registered SNAC preprocessor to process an incoming SNAC packet. |
Constructor Summary | |
protected |
AbstractSnacProcessor(FlapProcessor flapProcessor)
Creates a new SNAC processor attached to the given FLAP processor. |
Method Summary | |
void |
addPacketListener(SnacPacketListener l)
Adds a packet listener to listen for incoming SNAC packets. |
void |
addPreprocessor(SnacPreprocessor p)
Adds a SNAC preprocessor to the list of preprocessors. |
void |
addVetoablePacketListener(VetoableSnacPacketListener l)
Adds a vetoable packet listener to this SNAC processor. |
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 current FLAP processor without clearing any queued SNAC requests. |
CmdFactoryMgr |
getCmdFactoryMgr()
Returns this SNAC processor's SNAC command factory manager. |
FlapProcessor |
getFlapProcessor()
Returns the FLAP processor to which this SNAC processor is attached. |
boolean |
isAttached()
Returns whether this SNAC processor is attached to its FLAP processor. |
protected void |
migrate(FlapProcessor processor)
"Reattaches" or "migrates" to the given FLAP processor. |
void |
removePacketListener(SnacPacketListener l)
Removes a packet listener from the list of listeners. |
void |
removePreprocessor(SnacPreprocessor p)
Removes a SNAC preprocessor from the list of SNAC preprocessors. |
void |
removeVetoablePacketListener(VetoableSnacPacketListener l)
Removes a vetoable packet listener from the list of listeners. |
protected void |
sendSnac(long reqid,
SnacCommand cmd)
Sends the given SNAC command with the given SNAC request ID over the currently attached FLAP processor. |
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_PACKET_PREPROCESSOR
getReason()
) will be
the SnacPreprocessor
that threw the exception.
public static final java.lang.Object ERRTYPE_SNAC_PACKET_LISTENER
getReason()
) will be
the VetoableFlapPacketListener
or
FlapPacketListener
from whence the exception was thrown.
Constructor Detail |
protected AbstractSnacProcessor(FlapProcessor flapProcessor)
flapProcessor
- the FLAP processor to which to attachMethod Detail |
protected void migrate(FlapProcessor processor)
processor
- the FLAP processor to which to migratepublic final FlapProcessor getFlapProcessor()
public final boolean isAttached()
detach()
public void detach()
public final void addPacketListener(SnacPacketListener l)
l
- the listener to addpublic final void removePacketListener(SnacPacketListener l)
l
- the listener to removepublic final void addVetoablePacketListener(VetoableSnacPacketListener l)
l
- the listener to add.public final void removeVetoablePacketListener(VetoableSnacPacketListener l)
l
- the listener to removepublic final void addPreprocessor(SnacPreprocessor p)
p
- the preprocessor to addpublic final void removePreprocessor(SnacPreprocessor p)
p
- the preprocessor to removepublic final CmdFactoryMgr getCmdFactoryMgr()
protected boolean continueHandling(SnacPacketEvent event)
true
.)
event
- the event
protected final void sendSnac(long reqid, SnacCommand cmd)
reqid
- the request ID of the SNAC packet to sendcmd
- the SNAC command to use in generating the SNAC packet
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |