25
25
import au.edu.unimelb.csse.mugle.shared.api.GameTokenError;
26
26
import au.edu.unimelb.csse.mugle.shared.api.KeyError;
27
import au.edu.unimelb.csse.mugle.shared.multiplayer.api.InstanceTokenError;
29
* Developer API for accessing the key/value store.
30
* This allows each game to associate arbitrary data with string keys,
31
* independently for each user.
30
* Developer API for accessing the key/value store. This allows each game to
31
* associate arbitrary data with string keys, independently for each user.
33
33
@RemoteServiceRelativePath("api-keyvalue")
34
public interface KeyValueService extends RemoteService
36
/** Store an object in the key-value store.
37
* The value will be specific to the current user, and will only be able
38
* to be retrieved by the same user.
39
* @param gameToken The secret token for the current game.
40
* @param key The key to associate the object with.
41
* @param value The object to store.
34
public interface KeyValueService extends RemoteService {
36
* Store an object in the key-value store. The value will be specific to the
37
* current user, and will only be able to be retrieved by the same user.
40
* The secret token for the current game.
42
* The key to associate the object with.
44
* The object to store.
45
* @deprecated use {@link #put(String, String, Serializable, String)}
43
49
public void put(String gameToken, String key, Serializable value)
44
throws GameTokenError;
46
/** Retrieve an object from the key-value store.
47
* The value will be the one stored by the current user.
48
* @param gameToken The secret token for the current game.
49
* @param key The key the object is associated with.
50
throws GameTokenError;
53
* Store an object in the key-value store. The value will be specific to the
54
* current user, and will only be able to be retrieved by the same user.
57
* The secret token for the current game.
59
* The key to associate the object with.
61
* The object to store.
62
* @param instanceToken
63
* The secret token for the current game instance. If not null
64
* then it's retrieved from the user game instance profile.
65
* Otherwise it's retrieved from the user game profile.
67
public void put(String gameToken, String key, Serializable value,
68
String instanceToken) throws GameTokenError, InstanceTokenError;
71
* Retrieve an object from the key-value store. The value will be the one
72
* stored by the current user.
75
* The secret token for the current game.
77
* The key the object is associated with.
50
78
* @return The object associated with the key.
51
* @throws KeyError If no object is associated with that key.
80
* If no object is associated with that key.
81
* @deprecated use {@link #get(String, String, String)} instead.
53
84
public Serializable get(String gameToken, String key)
54
throws GameTokenError, KeyError;
56
/** Test whether a key has an associated object for the current user.
57
* @param gameToken The secret token for the current game.
58
* @param key The key the object is associated with.
85
throws GameTokenError, KeyError;
88
* Retrieve an object from the key-value store. The value will be the one
89
* stored by the current user.
92
* The secret token for the current game.
94
* The key the object is associated with.
95
* @param instanceToken
96
* The secret token for the current game instance. If not null
97
* then it's retrieved from the user game instance profile.
98
* Otherwise it's retrieved from the user game profile.
99
* @return The object associated with the key.
101
* If no object is associated with that key.
102
* @throws InstanceTokenError
104
public Serializable get(String gameToken, String key, String instanceToken)
105
throws GameTokenError, KeyError, InstanceTokenError;
108
* Test whether a key has an associated object for the current user.
111
* The secret token for the current game.
113
* The key the object is associated with.
59
114
* @return True if a value is associated with the key.
115
* @deprecated use {@link #containsKey(String, String, String)} instead.
61
118
public boolean containsKey(String gameToken, String key)
62
throws GameTokenError;
119
throws GameTokenError;
122
* Test whether a key has an associated object for the current user.
125
* The secret token for the current game.
127
* The key the object is associated with.
128
* @param instanceToken
129
* The secret token for the current game instance. If not null
130
* then it's retrieved from the user game instance profile.
131
* Otherwise it's retrieved from the user game profile.
132
* @return True if a value is associated with the key.
133
* @throws InstanceTokenError
135
public boolean containsKey(String gameToken, String key,
136
String instanceToken) throws GameTokenError, InstanceTokenError;