public class

SkylinkMessageCache

extends Object
java.lang.Object
   ↳ sg.com.temasys.skylink.sdk.messagecache.SkylinkMessageCache

Class Overview

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");
     
 }
 }

Summary

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

Public Methods

public void clearAll ()

Clears full local cache.

Throws
Exception If SDK cannot make proper connection to the local cache database.

public void clearRoom (String roomName)

Clears the cached room information and the cached messages of the room. Presence of the entire room will be removed from the local cache.

Parameters
roomName Skylink Room name
Throws
Exception If SDK cannot make proper connection to the local cache database.

public static synchronized SkylinkMessageCache getInstance ()

Gets the singleton instance of SkylinkMessageCache.

Returns

public SkylinkMessageCache.ReadableSession getReadableSession (String roomName)

Gets readable cache session that user can use SkylinkMessageCache.ReadableSession interface to read from cache.

Parameters
roomName Skylink Room name
Returns
Throws
Exception If SDK cannot make proper connection to the local cache database.

public SkylinkMessageCache.WritableSession getWritableSession (String roomName)

Gets writable cache session that user can use SkylinkMessageCache.WritableSession interface to write to cache or delete from cache.

Parameters
roomName Skylink Room name
Returns
Throws
Exception If SDK cannot make proper connection to the local cache database.

public boolean isEnabled ()

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.

Returns
  • True only if message caching is enabled in the SkylinkConfig object provided during SkylinkConnection.init(SkylinkConfig, Context, SkylinkCallback).