leafchat.core.api
Interface MsgOwner

All Known Implementing Classes:
BasicMsgOwner

public interface MsgOwner

Implemented by classes that dispatch messages.

This class does not need to be in a public .api package.


Method Summary
 boolean allowExternalDispatch(Msg m)
          Called if somebody tries to dispatch a message other than via the MessageDispatch class
 java.lang.String getFriendlyName()
          Return a friendly name (for display to users) of the message, which is not used for other purposes.
 java.lang.Class<? extends Msg> getMessageClass()
          Return the public class of messages dispatched by this object.
 void init(MessageDispatch md)
          Called once the dispatcher is registered.
 void manualDispatch(Msg m)
          Called when the dispatcher should handle manual dispatch of a message (to all targets for which it returned false in registerTarget).
 boolean registerTarget(java.lang.Object target, java.lang.Class<? extends Msg> message, MessageFilter mf, int requestID, int priority)
          Called when a new target registers to receive messages from this class.
 void unregisterTarget(java.lang.Object target, int requestID)
          Called when a target unregisters.
 

Method Detail

init

void init(MessageDispatch md)
Called once the dispatcher is registered.

Parameters:
md - Provided by the system to handle message dispatch from this dispatcher

getFriendlyName

java.lang.String getFriendlyName()
Return a friendly name (for display to users) of the message, which is not used for other purposes.

Returns:
Friendly name

getMessageClass

java.lang.Class<? extends Msg> getMessageClass()
Return the public class of messages dispatched by this object. This should normally be an interface or simple object, and must reside in a .api package. If the owner dispatches multiple messages, this should be the base class.

Returns:
Class of messages

registerTarget

boolean registerTarget(java.lang.Object target,
                       java.lang.Class<? extends Msg> message,
                       MessageFilter mf,
                       int requestID,
                       int priority)
Called when a new target registers to receive messages from this class.

Parameters:
target - Target
message - Class of desired message (null = all)
mf - Filter (may be null)
requestID - ID associated with this request (used in unregister)
priority - Priority for message
Returns:
True if the system should automatically dispatch messages to this target; false if this MessageOwner will dispatch messages itself

unregisterTarget

void unregisterTarget(java.lang.Object target,
                      int requestID)
Called when a target unregisters.

Parameters:
target - Target
requestID - Identifier of the request to be removed

manualDispatch

void manualDispatch(Msg m)
Called when the dispatcher should handle manual dispatch of a message (to all targets for which it returned false in registerTarget). Manual dispatch happens *before* any automatic dispatching.

It is up to the message owner to handle 'stopped' messages (m.isStopped) and not pass them on to further targets.

Parameters:
m - Message being sent

allowExternalDispatch

boolean allowExternalDispatch(Msg m)
Called if somebody tries to dispatch a message other than via the MessageDispatch class

Parameters:
m - Message for dispatch
Returns:
True to permit dispatch, false to prohibit


Copyright © 2011 Samuel Marshall. All rights reserved.