public class GameStateManager extends Object implements GameStateManagerService
Modifier and Type | Field and Description |
---|---|
private static org.slf4j.Logger |
LOG |
(package private) byte[] |
serializedBytes |
private Object |
state |
private AtomicInteger |
syncKey |
Constructor and Description |
---|
GameStateManager() |
GameStateManager(Object state,
AtomicInteger syncKey) |
Modifier and Type | Method and Description |
---|---|
boolean |
compareAndSetState(Object key,
Object state)
This method is actually a combination of compareAndSetSyncKey and
setState.
|
boolean |
compareAndSetSyncKey(Object key)
Method used to achieve synchronization while doing state management.
|
Object |
computeAndSetNextState(Object state,
Object syncKey,
Object stateAlgorithm) |
Object |
computeNextState(Object state,
Object syncKey,
Object stateAlgorithm) |
Object |
getAndSetState(Object state)
Set the state of the object.
|
byte[] |
getSerializedByteArray()
Whenever serialization is done from Java object to AMF3, or just plain
seriazlied java object, it should be saved in byte array format to the
state manager.
|
Object |
getState() |
Object |
getStateAlgorithm() |
Object |
getSyncKey()
Method used to retrieve the synchronization key object.
|
void |
setSerializedByteArray(byte[] serializedBytes)
Whenever serialization is done from Java object to AMF3, or just plain
java serialized object, it should be saved in byte array format to the
state manager.
|
private static final org.slf4j.Logger LOG
private Object state
byte[] serializedBytes
private AtomicInteger syncKey
public GameStateManager()
public GameStateManager(Object state, AtomicInteger syncKey)
public Object getState()
getState
in interface GameStateManagerService
public Object getAndSetState(Object state)
GameStateManagerService
getAndSetState
in interface GameStateManagerService
public boolean compareAndSetState(Object key, Object state)
GameStateManagerService
compareAndSetState
in interface GameStateManagerService
key
- Sync key of the incoming objectstate
- The new state to be set.public Object getSyncKey()
GameStateManagerService
getSyncKey
in interface GameStateManagerService
public boolean compareAndSetSyncKey(Object key)
GameStateManagerService
compareAndSetSyncKey
in interface GameStateManagerService
key
- The current state is wrapped in this object key.public byte[] getSerializedByteArray()
GameStateManagerService
getSerializedByteArray
in interface GameStateManagerService
public void setSerializedByteArray(byte[] serializedBytes)
GameStateManagerService
setSerializedByteArray
in interface GameStateManagerService
serializedBytes
- the serialized AMF3 or other object in byte array format.public Object computeAndSetNextState(Object state, Object syncKey, Object stateAlgorithm) throws UnsupportedOperationException
computeAndSetNextState
in interface GameStateManagerService
UnsupportedOperationException
public Object computeNextState(Object state, Object syncKey, Object stateAlgorithm) throws UnsupportedOperationException
computeNextState
in interface GameStateManagerService
UnsupportedOperationException
public Object getStateAlgorithm() throws UnsupportedOperationException
getStateAlgorithm
in interface GameStateManagerService
UnsupportedOperationException
Copyright © 2013. All Rights Reserved.