|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.juoserver.protocol.ControllerImpl
public class ControllerImpl
Base controller class. A different instance of this class will be associated to each client's session.
This class adopts a modified version of the visitor pattern in order to handle theMessage
request instances: instead of placing an
accept() method on every Message
class and then having them
call something like visitor.handle( this ), the
getReply(Message)
method detects the specific subclass of the
Message
parameter and invokes the right handler method. The same
pattern is adopted in order to implement the postProcess(Message)
method.
The detected methods are lazily saved into the handlers
and
postProcessors
maps, which are static according to the fly-weight
pattern, because they do not depend on the specific client whose conversation
is being controlled.
Constructor Summary | |
---|---|
ControllerImpl(ClientHandler clientHandler,
Core core,
ClientMovementTracker movementTracker,
Configuration configuration)
Builds a new controller and attaches it to the specified ClientHandler . |
Method Summary | |
---|---|
protected List<Message> |
asList(Message... serverList)
|
void |
attach()
Detach the listener from the communication network. |
void |
detach()
Attach the listener to the communication network. |
boolean |
equals(Object obj)
|
Account |
getAccount()
|
UOObject |
getMobile()
|
List<Message> |
getReply(Message request)
Retrieves the reply for a certain request message. |
Message |
handle(CharacterSelect request)
|
List<Message> |
handle(ClientVersion clientVersion)
|
List<? extends Message> |
handle(DoubleClick doubleClick)
|
List<Message> |
handle(DropItem dropItem)
|
Message |
handle(GeneralInformation info)
|
Message |
handle(GetPlayerStatus gps)
|
Message |
handle(LoginRequest request)
|
Message |
handle(LoginSeed seed)
|
Message |
handle(LookRequest lookRequest)
|
List<Message> |
handle(MegaClilocRequest mcr)
Handles tooltips requests. |
List<Message> |
handle(MovementAck synchRequest)
Handles possible client's position synchronization requests. |
List<Message> |
handle(MoveRequest request)
Answers with the same sequence, increments the internal sequence (0 --> 256 and then always restart from 1). |
Message |
handle(PickUpItem pickUpItem)
|
Message |
handle(PingPong ping)
|
Message |
handle(SelectServer request)
|
Message |
handle(ServerLoginRequest request)
|
Message |
handle(SpyOnClient spyOnClient)
|
Message |
handle(UnicodeSpeechRequest request)
|
Message |
handle(WearItem wearItem)
|
int |
hashCode()
|
boolean |
isConversationActive()
|
void |
onChangedClothes(Mobile wearingMobile)
Receives the notification that the specified mobile has changed their clothes. |
void |
onEnteredRange(Mobile entered,
UOObject target)
Receives an update about a mobile, entered , which enters
another mobile's, target , range. |
void |
onItemDropped(Mobile droppingMobile,
Item item,
int targetSerialId,
int targetX,
int targetY,
int targetZ)
Receives the notification about an item being dropped. |
void |
onOtherMobileMovement(Mobile moving)
Receives an update about another mobile's movement. |
void |
onOtherMobileSpeech(Mobile speaker,
MessageType type,
int hue,
int font,
String language,
String text)
Receives an update about another mobile's speech. |
void |
postProcess(DropItem dropItem)
|
void |
postProcess(Message request)
Post-processes the request message. |
void |
postProcess(MoveRequest request)
Let the other clients know about this movement. |
void |
postProcess(WearItem wearItem)
|
void |
setAccount(Account account)
|
void |
setMobile(Mobile mobile)
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ControllerImpl(ClientHandler clientHandler, Core core, ClientMovementTracker movementTracker, Configuration configuration)
ClientHandler
.
clientHandler
- client handler to attach
this controller tocore
- the coremovementTracker
- a movement trackerconfiguration
- the used configurationMethod Detail |
---|
public List<Message> getReply(Message request)
ProtocolController
getReply
in interface ProtocolController
request
- request message
public void postProcess(Message request)
ProtocolController
postProcess
in interface ProtocolController
request
- the request message to be post-processedpublic boolean isConversationActive()
isConversationActive
in interface ProtocolController
true
if and only if the conversation with the client is still activepublic void attach()
IntercomListener
attach
in interface IntercomListener
public void detach()
IntercomListener
detach
in interface IntercomListener
public Message handle(LoginRequest request)
public Message handle(SelectServer request)
public Message handle(ServerLoginRequest request)
public Message handle(CharacterSelect request)
public List<Message> handle(ClientVersion clientVersion)
public List<Message> handle(MoveRequest request)
request
- movement request
IntercomException
- in case an inter-client error occurspublic void postProcess(MoveRequest request)
request
- movement request
IntercomException
- in case of inter-client communication errorspublic List<Message> handle(MovementAck synchRequest)
synchRequest
- synchronization request
public void onOtherMobileMovement(Mobile moving)
IntercomListener
onOtherMobileMovement
in interface IntercomListener
moving
- the other, moving mobilepublic void onEnteredRange(Mobile entered, UOObject target)
IntercomListener
entered
, which enters
another mobile's, target
, range.
onEnteredRange
in interface IntercomListener
entered
- the mobile who has entered the target's rangetarget
- the mobile whose range is being enteredpublic Message handle(UnicodeSpeechRequest request)
public void onOtherMobileSpeech(Mobile speaker, MessageType type, int hue, int font, String language, String text)
IntercomListener
onOtherMobileSpeech
in interface IntercomListener
speaker
- the speaking mobiletype
- message typehue
- message colourfont
- message fontlanguage
- message languagetext
- message textpublic List<Message> handle(MegaClilocRequest mcr)
mcr
- request
public Message handle(PingPong ping)
public Message handle(GetPlayerStatus gps)
public List<? extends Message> handle(DoubleClick doubleClick)
public Message handle(GeneralInformation info)
public Message handle(LoginSeed seed)
public Message handle(SpyOnClient spyOnClient)
public Message handle(LookRequest lookRequest)
public List<Message> handle(DropItem dropItem)
public void postProcess(DropItem dropItem)
public void onItemDropped(Mobile droppingMobile, Item item, int targetSerialId, int targetX, int targetY, int targetZ)
IntercomListener
onItemDropped
in interface IntercomListener
droppingMobile
- mobile dropping the itemitem
- itemtargetSerialId
- target serial IDtargetX
- target XtargetY
- target YtargetZ
- target Zpublic Message handle(PickUpItem pickUpItem)
public Message handle(WearItem wearItem)
public void postProcess(WearItem wearItem)
public void onChangedClothes(Mobile wearingMobile)
IntercomListener
onChangedClothes
in interface IntercomListener
wearingMobile
- the mobile changing their clothesprotected List<Message> asList(Message... serverList)
public int hashCode()
hashCode
in class Object
public boolean equals(Object obj)
equals
in class Object
public String toString()
toString
in class Object
public Account getAccount()
public void setAccount(Account account)
public UOObject getMobile()
public void setMobile(Mobile mobile)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |