java.lang.Object | |
↳ | sg.com.temasys.skylink.sdk.messagecache.SkylinkMessageCache |
Interfacing class that user needs to use the Skylink message caching feature. A singleton class.
// Example code of getting cached messages.
// Assuming all cached messages are String messages (not JSONObject or JSONArray messages).
if ( SkylinkMessageCache.getInstance().isEnabled() ) {
JSONArray cachedMsgs = SkylinkMessageCache.getInstance().getReadableSession("<your-room-name>").getCachedMessages();
for (int i = 0; i < cachedMsgs.length(); i++) {
JSONObject cachedMsg = (JSONObject) cachedMsgs.get(i);
String senderId = cachedMsg.getString("senderId");
String msgContent = cachedMsg.getString("data");
long timestamp = cachedMsg.getLong("timeStamp");
}
}
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
interface | SkylinkMessageCache.ReadableSession | Interface used to read from the local cache. | |||||||||
interface | SkylinkMessageCache.WritableSession | Interface used to make changes to the local cache. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
clearAll()
Clears full local cache.
| ||||||||||
void |
clearRoom(String roomName)
Clears the cached room information and the cached messages of the room.
| ||||||||||
synchronized static SkylinkMessageCache |
getInstance()
Gets the singleton instance of
SkylinkMessageCache . | ||||||||||
SkylinkMessageCache.ReadableSession |
getReadableSession(String roomName)
Gets readable cache session that user can use
SkylinkMessageCache.ReadableSession interface to read from cache. | ||||||||||
SkylinkMessageCache.WritableSession |
getWritableSession(String roomName)
Gets writable cache session that user can use
SkylinkMessageCache.WritableSession interface to write to cache or delete from cache. | ||||||||||
boolean |
isEnabled()
Is message caching feature is enabled?
Message caching can be enabled using SkylinkConfig.setMessageCachingEnable(boolean) method.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Clears full local cache.
Exception | If SDK cannot make proper connection to the local cache database. |
---|
Clears the cached room information and the cached messages of the room. Presence of the entire room will be removed from the local cache.
roomName | Skylink Room name |
---|
Exception | If SDK cannot make proper connection to the local cache database. |
---|
Gets the singleton instance of SkylinkMessageCache
.
SkylinkMessageCache
.
Gets readable cache session that user can use SkylinkMessageCache.ReadableSession
interface to read from cache.
roomName | Skylink Room name |
---|
SkylinkMessageCache.ReadableSession
object that user can use to read cached messages.Exception | If SDK cannot make proper connection to the local cache database. |
---|
Gets writable cache session that user can use SkylinkMessageCache.WritableSession
interface to write to cache or delete from cache.
roomName | Skylink Room name |
---|
SkylinkMessageCache.WritableSession
object that user can use to write to cache or delete from cache.Exception | If SDK cannot make proper connection to the local cache database. |
---|
Is message caching feature is enabled? Message caching can be enabled using SkylinkConfig.setMessageCachingEnable(boolean) method. Message caching enabled SkylinkConfig object should be provided during SkylinkConnection.init(SkylinkConfig, Context, SkylinkCallback) call to successfully the feature.