Class DefaultCrossfireServerConnection
java.lang.Object
com.realtime.crossfire.jxclient.server.crossfire.AbstractCrossfireServerConnection
com.realtime.crossfire.jxclient.server.crossfire.DefaultCrossfireServerConnection
- All Implemented Interfaces:
AskfaceQueue,CrossfireServerConnection,ServerConnection
Default implementation of
CrossfireServerConnection.-
Field Summary
Fields inherited from class com.realtime.crossfire.jxclient.server.crossfire.AbstractCrossfireServerConnection
UTF8 -
Constructor Summary
ConstructorsConstructorDescriptionDefaultCrossfireServerConnection(@NotNull Model model, @Nullable DebugWriter debugProtocol, @NotNull String version) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddClientSocketListener(@NotNull ClientSocketListener clientSocketListener) Adds aClientSocketListenerto notify.voidaddCrossfireMapScrollListener(@NotNull CrossfireMapScrollListener listener) Registers a listener to be called whenever the map was scolled.voidaddFaceReceivedListener(@NotNull AskfaceFaceQueueListener listener) Registers a listener to be called whenever a face has been received.voidAttempts to connect the client to a server.voiddisconnect(@NotNull String reason) Disconnects from the server.@Nullable StringReturns the current account name.intReturns the currently negotiated setup value of "num_look_objects".voidremoveClientSocketListener(@NotNull ClientSocketListener clientSocketListener) Removes aClientSocketListenerto notify.voidsendAccountCharacterCreate(@NotNull String login, @NotNull String password, @NotNull Collection<String> attributes) Sends a request to create a new character associated to the account.voidsendAccountCreate(@NotNull String login, @NotNull String password) Sends a request to create a new account.voidsendAccountLink(int force, @NotNull String login, @NotNull String password) Sends a request to add an existing character to an account.voidsendAccountLogin(@NotNull String login, @NotNull String password) Asks for an account login.voidsendAccountPassword(@NotNull String currentPassword, @NotNull String newPassword) Sends a request to change the account's password.voidsendAccountPlay(@NotNull String name) Sends a request to play a character from an account.voidSends an "addme" command to the server.voidsendApply(int tag) Sends an "apply" command to the server.voidsendAskface(int faceNum) Sends an "askface" command.voidsendExamine(int tag) Sends an "examine" command to the server.voidsendLock(boolean val, int tag) Sends a "lock" command to the server.voidsendLookat(int dx, int dy) Sends a "lookat" command to the server.voidsendMark(int tag) Sends a "mark" command to the server.voidsendMove(int to, int tag, int nrof) Sends a "move" command to the server.intSends a "ncom" command to the server.voidsendRawString(@NotNull String command) Sends an arbitrary string command to the server.voidSends a "reply" command to the server.voidsendRequestinfo(@NotNull String infoType) Sends a "requestinfo" command to the server.voidSends a "setup" command to the server.voidsendToggleextendedtext(@org.jetbrains.annotations.NotNull int... types) Sends a "toggleextendedtext" command to the server.voidsendVersion(int csval, int scval, @NotNull String vinfo) Sends a "version" command to the server.voidsetCrossfireUpdateMapListener(@NotNull CrossfireUpdateMapListener listener) Sets a listener to be notified about map changes.voidsetPreferredMapSize(int preferredMapWidth, int preferredMapHeight) Sets the preferred map size.voidsetPreferredNumLookObjects(int preferredNumLookObjects) Sets the maximum number of objects in the ground view.voidstart()Starts operation.voidstop()Stops operation.voidWaits untilgetCurrentNumLookObjects()is stable.Methods inherited from class com.realtime.crossfire.jxclient.server.crossfire.AbstractCrossfireServerConnection
addCrossfireAccountListener, addCrossfireComcListener, addCrossfireDrawextinfoListener, addCrossfireDrawinfoListener, addCrossfireFailureListener, addCrossfireMagicmapListener, addCrossfireMusicListener, addCrossfirePickupListener, addCrossfireQueryListener, addCrossfireSoundListener, addCrossfireTickListener, addCrossfireUpdateItemListener, addPacketWatcherListener, addSentPacketListener, clearFailure, drawextinfo, drawInfo, drawInfoSetDebugMode, fireAddAccount, fireAddItemReceived, fireCommandComcReceived, fireCommandQueryReceived, fireCommandSound2Received, fireCommandSoundReceived, fireDelinvReceived, fireDelitemReceived, fireEndAccountList, fireFaceReceived, fireFailure, fireMagicMap, fireManageAccount, fireMarkSent, fireMusicReceived, firePickupChanged, firePlayerReceived, fireReplySent, fireSelectCharacter, fireStartAccountList, fireStartPlaying, fireTick, fireUpditemReceived, newString, notifyPacketWatcherListeners, removeCrossfireAccountListener, removeCrossfireDrawextinfoListener, removeCrossfireDrawinfoListener, removeCrossfireFailureListener, removeCrossfireMagicmapListener, removeCrossfirePickupListener, removeCrossfireQueryListener, removeCrossfireUpdateItemListener, removePacketWatcherListener, removeSentPacketListener
-
Constructor Details
-
DefaultCrossfireServerConnection
public DefaultCrossfireServerConnection(@NotNull @NotNull Model model, @Nullable @Nullable DebugWriter debugProtocol, @NotNull @NotNull String version) throws IOException Creates a new instance.- Parameters:
model- the model instance to updatedebugProtocol- if non-null, write all protocol commands to this writerversion- the version information to send to the server when connecting- Throws:
IOException- if an internal error occurs
-
-
Method Details
-
setCrossfireUpdateMapListener
Description copied from interface:CrossfireServerConnectionSets a listener to be notified about map changes. At most one such listener may be set.- Parameters:
listener- the listener
-
start
public void start()Description copied from interface:CrossfireServerConnectionStarts operation. -
stop
Description copied from interface:CrossfireServerConnectionStops operation.- Throws:
InterruptedException- if stopping was interrupted
-
addCrossfireMapScrollListener
Description copied from interface:CrossfireServerConnectionRegisters a listener to be called whenever the map was scolled.- Parameters:
listener- the listener
-
sendAccountLogin
Description copied from interface:CrossfireServerConnectionAsks for an account login.- Parameters:
login- the account loginpassword- the account password
-
sendAddme
public void sendAddme()Description copied from interface:CrossfireServerConnectionSends an "addme" command to the server. -
sendApply
public void sendApply(int tag) Description copied from interface:CrossfireServerConnectionSends an "apply" command to the server.- Parameters:
tag- the item to apply
-
sendAskface
public void sendAskface(int faceNum) Description copied from interface:AskfaceQueueSends an "askface" command.- Parameters:
faceNum- the face number to request
-
addFaceReceivedListener
Description copied from interface:AskfaceQueueRegisters a listener to be called whenever a face has been received.- Parameters:
listener- the listener
-
sendExamine
public void sendExamine(int tag) Description copied from interface:CrossfireServerConnectionSends an "examine" command to the server.- Parameters:
tag- the item to examine
-
sendLock
public void sendLock(boolean val, int tag) Description copied from interface:CrossfireServerConnectionSends a "lock" command to the server.- Parameters:
val- whether to lock the itemtag- the item to lock
-
sendLookat
public void sendLookat(int dx, int dy) Description copied from interface:CrossfireServerConnectionSends a "lookat" command to the server.- Parameters:
dx- the x-coordinate in tiles, relative to the playerdy- the y-coordinate in tiles, relative to the player
-
sendMark
public void sendMark(int tag) Description copied from interface:CrossfireServerConnectionSends a "mark" command to the server.- Parameters:
tag- the item to mark
-
sendMove
public void sendMove(int to, int tag, int nrof) Description copied from interface:CrossfireServerConnectionSends a "move" command to the server.- Parameters:
to- the destination locationtag- the item to movenrof- the number of items to move
-
sendNcom
Description copied from interface:CrossfireServerConnectionSends a "ncom" command to the server.- Parameters:
repeat- the repeat countcommand- the command- Returns:
- the packet id
-
sendRawString
Description copied from interface:CrossfireServerConnectionSends an arbitrary string command to the server.- Parameters:
command- the command
-
sendReply
Description copied from interface:CrossfireServerConnectionSends a "reply" command to the server.- Parameters:
text- the text to reply
-
sendRequestinfo
Description copied from interface:CrossfireServerConnectionSends a "requestinfo" command to the server.- Parameters:
infoType- the info type to request
-
sendSetup
Description copied from interface:CrossfireServerConnectionSends a "setup" command to the server.- Parameters:
options- the option/value pairs to send
-
sendToggleextendedtext
public void sendToggleextendedtext(@NotNull @org.jetbrains.annotations.NotNull int... types) Description copied from interface:CrossfireServerConnectionSends a "toggleextendedtext" command to the server.- Parameters:
types- the types to request
-
sendVersion
Description copied from interface:CrossfireServerConnectionSends a "version" command to the server.- Parameters:
csval- the client version numberscval- the server version numbervinfo- the client identification string
-
setPreferredMapSize
public void setPreferredMapSize(int preferredMapWidth, int preferredMapHeight) Description copied from interface:CrossfireServerConnectionSets the preferred map size.- Parameters:
preferredMapWidth- the preferred map width in tiles; must be oddpreferredMapHeight- the preferred map height in tiles; must be odd
-
setPreferredNumLookObjects
public void setPreferredNumLookObjects(int preferredNumLookObjects) Description copied from interface:CrossfireServerConnectionSets the maximum number of objects in the ground view. Must not be called in connected state.- Parameters:
preferredNumLookObjects- the number of objects
-
getAccountName
Description copied from interface:CrossfireServerConnectionReturns the current account name.- Returns:
- the current account name or
null
-
connect
Description copied from interface:ServerConnectionAttempts to connect the client to a server.- Parameters:
hostname- the hostname to connect toport- the port to connect to
-
disconnect
Description copied from interface:ServerConnectionDisconnects from the server. Does nothing if not connected.- Parameters:
reason- the reason for the disconnect
-
addClientSocketListener
Description copied from interface:ServerConnectionAdds aClientSocketListenerto notify.- Parameters:
clientSocketListener- the client socket listener to add
-
removeClientSocketListener
Description copied from interface:ServerConnectionRemoves aClientSocketListenerto notify.- Parameters:
clientSocketListener- the client socket listener to remove
-
sendAccountPlay
Description copied from interface:CrossfireServerConnectionSends a request to play a character from an account.- Parameters:
name- the character's name to play
-
sendAccountLink
public void sendAccountLink(int force, @NotNull @NotNull String login, @NotNull @NotNull String password) Description copied from interface:CrossfireServerConnectionSends a request to add an existing character to an account.- Parameters:
force- 0 to allow failure, 1 to force in certain situationslogin- the character's loginpassword- the character's password
-
sendAccountCreate
Description copied from interface:CrossfireServerConnectionSends a request to create a new account.- Parameters:
login- the account loginpassword- the account password
-
sendAccountCharacterCreate
public void sendAccountCharacterCreate(@NotNull @NotNull String login, @NotNull @NotNull String password, @NotNull @NotNull Collection<String> attributes) Description copied from interface:CrossfireServerConnectionSends a request to create a new character associated to the account.- Parameters:
login- the character's namepassword- the character's passwordattributes- the character attributes
-
sendAccountPassword
public void sendAccountPassword(@NotNull @NotNull String currentPassword, @NotNull @NotNull String newPassword) Description copied from interface:CrossfireServerConnectionSends a request to change the account's password.- Parameters:
currentPassword- current account passwordnewPassword- new account password
-
getCurrentNumLookObjects
public int getCurrentNumLookObjects()Returns the currently negotiated setup value of "num_look_objects".- Returns:
- the current size of the ground view
-
waitForCurrentNumLookObjectsValid
Waits untilgetCurrentNumLookObjects()is stable. This function returns as soon as the negotiation with the Crossfire server is complete.- Throws:
InterruptedException- if the current thread was interrupted
-