public class DefaultCrossfireServerConnection extends AbstractCrossfireServerConnection
CrossfireServerConnection
.UTF8
Constructor and Description |
---|
DefaultCrossfireServerConnection(@NotNull Model model,
@Nullable DebugWriter debugProtocol,
@NotNull java.lang.String version)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addClientSocketListener(@NotNull ClientSocketListener clientSocketListener)
Adds a
ClientSocketListener to notify. |
void |
addCrossfireMapScrollListener(@NotNull CrossfireMapScrollListener listener)
Registers a listener to be called whenever the map was scolled.
|
void |
addFaceReceivedListener(@NotNull AskfaceFaceQueueListener listener)
Registers a listener to be called whenever a face has been received.
|
void |
connect(@NotNull java.lang.String hostname,
int port)
Attempts to connect the client to a server.
|
void |
disconnect(@NotNull java.lang.String reason)
Disconnects from the server.
|
@Nullable java.lang.String |
getAccountName()
Returns the current account name.
|
int |
getCurrentNumLookObjects()
Returns the currently negotiated setup value of "num_look_objects".
|
void |
removeClientSocketListener(@NotNull ClientSocketListener clientSocketListener)
Removes a
ClientSocketListener to notify. |
void |
sendAccountCharacterCreate(@NotNull java.lang.String login,
@NotNull java.lang.String password,
@NotNull java.util.Collection<java.lang.String> attributes)
Sends a request to create a new character associated to the account.
|
void |
sendAccountCreate(@NotNull java.lang.String login,
@NotNull java.lang.String password)
Sends a request to create a new account.
|
void |
sendAccountLink(int force,
@NotNull java.lang.String login,
@NotNull java.lang.String password)
Sends a request to add an existing character to an account.
|
void |
sendAccountLogin(@NotNull java.lang.String login,
@NotNull java.lang.String password)
Asks for an account login.
|
void |
sendAccountPassword(@NotNull java.lang.String currentPassword,
@NotNull java.lang.String newPassword)
Sends a request to change the account's password.
|
void |
sendAccountPlay(@NotNull java.lang.String name)
Sends a request to play a character from an account.
|
void |
sendAddme()
Sends an "addme" command to the server.
|
void |
sendApply(int tag)
Sends an "apply" command to the server.
|
void |
sendAskface(int faceNum)
Sends an "askface" command.
|
void |
sendExamine(int tag)
Sends an "examine" command to the server.
|
void |
sendLock(boolean val,
int tag)
Sends a "lock" command to the server.
|
void |
sendLookat(int dx,
int dy)
Sends a "lookat" command to the server.
|
void |
sendMark(int tag)
Sends a "mark" command to the server.
|
void |
sendMove(int to,
int tag,
int nrof)
Sends a "move" command to the server.
|
int |
sendNcom(int repeat,
@NotNull java.lang.String command)
Sends a "ncom" command to the server.
|
void |
sendRawString(@NotNull java.lang.String command)
Sends an arbitrary string command to the server.
|
void |
sendReply(@NotNull java.lang.String text)
Sends a "reply" command to the server.
|
void |
sendRequestinfo(@NotNull java.lang.String infoType)
Sends a "requestinfo" command to the server.
|
void |
sendSetup(java.lang.String... options)
Sends a "setup" command to the server.
|
void |
sendToggleextendedtext(int... types)
Sends a "toggleextendedtext" command to the server.
|
void |
sendVersion(int csval,
int scval,
@NotNull java.lang.String vinfo)
Sends a "version" command to the server.
|
void |
setCrossfireUpdateMapListener(@NotNull CrossfireUpdateMapListener listener)
Sets a listener to be notified about map changes.
|
void |
setPreferredMapSize(int preferredMapWidth,
int preferredMapHeight)
Sets the preferred map size.
|
void |
setPreferredNumLookObjects(int preferredNumLookObjects)
Sets the maximum number of objects in the ground view.
|
void |
start()
Starts operation.
|
void |
stop()
Stops operation.
|
void |
waitForCurrentNumLookObjectsValid()
Waits until
getCurrentNumLookObjects() is stable. |
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
public DefaultCrossfireServerConnection(@NotNull @NotNull Model model, @Nullable @Nullable DebugWriter debugProtocol, @NotNull @NotNull java.lang.String version) throws java.io.IOException
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
connectingjava.io.IOException
- if an internal error occurspublic void setCrossfireUpdateMapListener(@NotNull @NotNull CrossfireUpdateMapListener listener)
CrossfireServerConnection
listener
- the listenerpublic void start()
CrossfireServerConnection
public void stop() throws java.lang.InterruptedException
CrossfireServerConnection
java.lang.InterruptedException
- if stopping was interruptedpublic void addCrossfireMapScrollListener(@NotNull @NotNull CrossfireMapScrollListener listener)
CrossfireServerConnection
listener
- the listenerpublic void sendAccountLogin(@NotNull @NotNull java.lang.String login, @NotNull @NotNull java.lang.String password)
CrossfireServerConnection
login
- the account loginpassword
- the account passwordpublic void sendAddme()
CrossfireServerConnection
public void sendApply(int tag)
CrossfireServerConnection
tag
- the item to applypublic void sendAskface(int faceNum)
AskfaceQueue
faceNum
- the face number to requestpublic void addFaceReceivedListener(@NotNull @NotNull AskfaceFaceQueueListener listener)
AskfaceQueue
listener
- the listenerpublic void sendExamine(int tag)
CrossfireServerConnection
tag
- the item to examinepublic void sendLock(boolean val, int tag)
CrossfireServerConnection
val
- whether to lock the itemtag
- the item to lockpublic void sendLookat(int dx, int dy)
CrossfireServerConnection
dx
- the x-coordinate in tiles, relative to the playerdy
- the y-coordinate in tiles, relative to the playerpublic void sendMark(int tag)
CrossfireServerConnection
tag
- the item to markpublic void sendMove(int to, int tag, int nrof)
CrossfireServerConnection
to
- the destination locationtag
- the item to movenrof
- the number of items to movepublic int sendNcom(int repeat, @NotNull @NotNull java.lang.String command)
CrossfireServerConnection
repeat
- the repeat countcommand
- the commandpublic void sendRawString(@NotNull @NotNull java.lang.String command)
CrossfireServerConnection
command
- the commandpublic void sendReply(@NotNull @NotNull java.lang.String text)
CrossfireServerConnection
text
- the text to replypublic void sendRequestinfo(@NotNull @NotNull java.lang.String infoType)
CrossfireServerConnection
infoType
- the info type to requestpublic void sendSetup(@NotNull java.lang.String... options)
CrossfireServerConnection
options
- the option/value pairs to sendpublic void sendToggleextendedtext(@NotNull int... types)
CrossfireServerConnection
types
- the types to requestpublic void sendVersion(int csval, int scval, @NotNull @NotNull java.lang.String vinfo)
CrossfireServerConnection
csval
- the client version numberscval
- the server version numbervinfo
- the client identification stringpublic void setPreferredMapSize(int preferredMapWidth, int preferredMapHeight)
CrossfireServerConnection
preferredMapWidth
- the preferred map width in tiles; must be oddpreferredMapHeight
- the preferred map height in tiles; must be oddpublic void setPreferredNumLookObjects(int preferredNumLookObjects)
CrossfireServerConnection
preferredNumLookObjects
- the number of objects@Nullable public @Nullable java.lang.String getAccountName()
CrossfireServerConnection
null
public void connect(@NotNull @NotNull java.lang.String hostname, int port)
ServerConnection
hostname
- the hostname to connect toport
- the port to connect topublic void disconnect(@NotNull @NotNull java.lang.String reason)
ServerConnection
reason
- the reason for the disconnectpublic void addClientSocketListener(@NotNull @NotNull ClientSocketListener clientSocketListener)
ServerConnection
ClientSocketListener
to notify.clientSocketListener
- the client socket listener to addpublic void removeClientSocketListener(@NotNull @NotNull ClientSocketListener clientSocketListener)
ServerConnection
ClientSocketListener
to notify.clientSocketListener
- the client socket listener to removepublic void sendAccountPlay(@NotNull @NotNull java.lang.String name)
CrossfireServerConnection
name
- the character's name to playpublic void sendAccountLink(int force, @NotNull @NotNull java.lang.String login, @NotNull @NotNull java.lang.String password)
CrossfireServerConnection
force
- 0 to allow failure, 1 to force in certain situationslogin
- the character's loginpassword
- the character's passwordpublic void sendAccountCreate(@NotNull @NotNull java.lang.String login, @NotNull @NotNull java.lang.String password)
CrossfireServerConnection
login
- the account loginpassword
- the account passwordpublic void sendAccountCharacterCreate(@NotNull @NotNull java.lang.String login, @NotNull @NotNull java.lang.String password, @NotNull @NotNull java.util.Collection<java.lang.String> attributes)
CrossfireServerConnection
login
- the character's namepassword
- the character's passwordattributes
- the character attributespublic void sendAccountPassword(@NotNull @NotNull java.lang.String currentPassword, @NotNull @NotNull java.lang.String newPassword)
CrossfireServerConnection
currentPassword
- current account passwordnewPassword
- new account passwordpublic int getCurrentNumLookObjects()
public void waitForCurrentNumLookObjectsValid() throws java.lang.InterruptedException
getCurrentNumLookObjects()
is stable. This function
returns as soon as the negotiation with the Crossfire server is
complete.java.lang.InterruptedException
- if the current thread was interrupted