com.realtime.crossfire.jxclient.faces
Class AskfaceFaceQueue

java.lang.Object
  extended by com.realtime.crossfire.jxclient.faces.AbstractFaceQueue
      extended by com.realtime.crossfire.jxclient.faces.AskfaceFaceQueue
All Implemented Interfaces:
FaceQueue

public class AskfaceFaceQueue
extends AbstractFaceQueue

A FaceQueue requesting faces by "askface" commands sent to the Crossfire server.


Field Summary
private static int CONCURRENT_ASKFACE_COMMANDS
          The maximum number of concurrently sent "askface" commands.
private  CrossfireServerConnection crossfireServerConnection
          The connection to use.
private  CrossfireUpdateFaceListener crossfireUpdateFaceListener
          The CrossfireUpdateFaceListener registered to crossfireServerConnection receive face commands.
private  java.util.Map<java.lang.Integer,Face> pendingAskfaces
          Face numbers for which "askface" commands have been sent without having received a response from the server.
private  java.util.Map<java.lang.Integer,Face> pendingFaces
          Face numbers for which an "askface" command should be sent.
private  java.util.List<Face> pendingFacesQueue
          The same elements as pendingFaces in query order.
private  java.lang.Object sync
          The object use for synchronization.
 
Constructor Summary
AskfaceFaceQueue(CrossfireServerConnection crossfireServerConnection)
          Creates a new instance.
 
Method Summary
private  void faceReceived(int faceNum, int faceSetNum, java.nio.ByteBuffer packet)
          Notifies the askface manager that image information have been received from the server.
 void loadFace(Face face)
          Request a face.
private  void processFaceData(Face face, byte[] data)
          Processes face information received from the server.
 void reset()
          Reset the processing: forget about pending faces.
private  void sendAskface()
          Sends some pending "askface" commands.
 
Methods inherited from class com.realtime.crossfire.jxclient.faces.AbstractFaceQueue
addFaceQueueListener, fireFaceFailed, fireFaceLoaded, removeFaceQueueListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONCURRENT_ASKFACE_COMMANDS

private static final int CONCURRENT_ASKFACE_COMMANDS
The maximum number of concurrently sent "askface" commands. If more are requested, the excess ones are put on hold until some face information is received.

See Also:
Constant Field Values

crossfireServerConnection

@Nullable
private final CrossfireServerConnection crossfireServerConnection
The connection to use.


crossfireUpdateFaceListener

@NotNull
private final CrossfireUpdateFaceListener crossfireUpdateFaceListener
The CrossfireUpdateFaceListener registered to crossfireServerConnection receive face commands.


pendingAskfaces

@NotNull
private final java.util.Map<java.lang.Integer,Face> pendingAskfaces
Face numbers for which "askface" commands have been sent without having received a response from the server. Maps face ID to Face instance.


pendingFaces

@NotNull
private final java.util.Map<java.lang.Integer,Face> pendingFaces
Face numbers for which an "askface" command should be sent. It includes all elements of pendingAskfaces.


pendingFacesQueue

@NotNull
private final java.util.List<Face> pendingFacesQueue
The same elements as pendingFaces in query order.


sync

@NotNull
private final java.lang.Object sync
The object use for synchronization.

Constructor Detail

AskfaceFaceQueue

public AskfaceFaceQueue(@Nullable
                        CrossfireServerConnection crossfireServerConnection)
Creates a new instance.

Parameters:
crossfireServerConnection - the connection instance for sending askface commands
Method Detail

faceReceived

private void faceReceived(int faceNum,
                          int faceSetNum,
                          @NotNull
                          java.nio.ByteBuffer packet)
Notifies the askface manager that image information have been received from the server.

Parameters:
faceNum - the face ID
faceSetNum - the face set
packet - the face data

loadFace

public void loadFace(@NotNull
                     Face face)
Request a face. Must eventually call either FaceQueueListener.faceLoaded(Face, FaceImages) or FaceQueueListener.faceFailed(Face) for the face. Faces re-requested while still processing may be notified only once.

Parameters:
face - the requested face

processFaceData

private void processFaceData(@NotNull
                             Face face,
                             @NotNull
                             byte[] data)
Processes face information received from the server.

Parameters:
face - the face
data - the face information; it is supposed to be a .png file

reset

public void reset()
Reset the processing: forget about pending faces. This function is called whenever the server socket breaks, or when a new connection has been established.


sendAskface

private void sendAskface()
Sends some pending "askface" commands.