public class

SkylinkConnection

extends Object
java.lang.Object
   ↳ sg.com.temasys.skylink.sdk.rtc.SkylinkConnection

Class Overview

Main class to connect to the skylink infrastructure.

Summary

Constants
int DEFAULT_DURATION Duration in hours after the start time when the room will be closed by the signalling server.
Public Methods
boolean connectToRoom(String skylinkConnectionString, Object userData)
Connects to a room with SkylinkConnectionString
boolean connectToRoom(String secret, String roomName, Object userData)
Connects to a room with the default duration of 24 hours and with the current time It is encouraged to use the method connectToRoom(String connectionString, Object userData)
void disconnectFromRoom()
Disconnects from the room we are currently in.
DataTransferListener getDataTransferListener()
FileTransferListener getFileTransferListener()
Handler getHandler()
synchronized static SkylinkConnection getInstance()
LifeCycleListener getLifeCycleListener()
Object getLockDisconnectSdp()
Object getLockDisconnectSdpCreate()
Object getLockDisconnectSdpDrain()
Object getLockDisconnectSdpSend()
Object getLockDisconnectSdpSet()
MediaListener getMediaListener()
MessagesListener getMessagesListener()
RemotePeerListener getRemotePeerListener()
Object getUserData(String remotePeerId)
Retrieves the user defined data object of a peer.
UserInfo getUserInfo(String remotePeerId)
Retrieves the UserInfo object of a Peer.
void init(String appKey, SkylinkConfig config, Context context)
Creates a new SkylinkConnection object with the specified parameters.
void lockRoom()
Locks the room if its not already locked
void muteLocalAudio(boolean isMuted)
Mutes the local user's audio and notifies all the peers in the room.
void muteLocalVideo(boolean isMuted)
Mutes the local user's video and notifies all the peers in the room.
void restartConnection(String remotePeerId)
Restarts a connection with a specific peer or all connections if remotePeerId is null
void sendData(String remotePeerId, byte[] data)
Sends a byte array to a specified remotePeer or to all participants of the room if the remotePeerId is null
void sendFileTransferPermissionRequest(String remotePeerId, String fileName, String filePath)
Sends request(s) to share file with a specific remote peer or to all remote peers in a direct peer to peer manner in the same room.
void sendFileTransferPermissionResponse(String remotePeerId, String filePath, boolean isPermitted)
Call this method to accept or reject the file share request from a remote peer.
void sendLocalUserData(Object userData)
Sends local user data related to oneself, to all remote peers in our room.
void sendP2PMessage(String remotePeerId, Object message)
Sends a user defined message to a specific remote peer or to all remote peers in a direct peer to peer manner.
void sendServerMessage(String remotePeerId, Object message)
Sends a user defined message to a specific remote peer or to all remote peers via a server.
void setDataTransferListener(DataTransferListener dataTransferListener)
Sets the specified data transfer listener object.
void setFileTransferListener(FileTransferListener fileTransferListener)
Sets the specified file transfer listener object.
void setLifeCycleListener(LifeCycleListener lifeCycleListener)
Sets the specified life cycle listener object.
void setMediaListener(MediaListener mediaListener)
Sets the specified media listener object that will receive callbacks related to Media Stream.
void setMessagesListener(MessagesListener messagesListener)
Sets the specified messages listener object.
void setRemotePeerListener(RemotePeerListener remotePeerListener)
Sets the specified remote peer listener object.
boolean switchCamera()
Call this method to switch between available camera.
void unlockRoom()
Unlocks the room if its already locked
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int DEFAULT_DURATION

Duration in hours after the start time when the room will be closed by the signalling server.

Constant Value: 24 (0x00000018)

Public Methods

public boolean connectToRoom (String skylinkConnectionString, Object userData)

Connects to a room with SkylinkConnectionString

Parameters
skylinkConnectionString SkylinkConnectionString Generated with room name, appKey, secret, startTime and duration
userData User defined data relating to oneself. May be a 'java.lang.String', 'org.json.JSONObject' or 'org.json.JSONArray'.
Returns
  • 'false' if the connection is already established

public boolean connectToRoom (String secret, String roomName, Object userData)

Connects to a room with the default duration of 24 hours and with the current time It is encouraged to use the method connectToRoom(String connectionString, Object userData)

Parameters
secret The secret associated with the key as registered with the Skylink Developer Console
roomName The name of the room
userData User defined data relating to oneself. May be a 'java.lang.String', 'org.json.JSONObject' or 'org.json.JSONArray'.
Returns
  • 'false' if the connection is already established

public void disconnectFromRoom ()

Disconnects from the room we are currently in.

Once disconnect is complete, onDisconnect(int, String) will be called.

To connect to a room after this, init(String, SkylinkConfig, Context) and connectToRoom(String, Object) will have to be called.

public DataTransferListener getDataTransferListener ()

Returns
  • The data transfer listener object.

public FileTransferListener getFileTransferListener ()

Returns
  • The file transfer listener object.

public Handler getHandler ()

public static synchronized SkylinkConnection getInstance ()

Returns
  • Existing instance of SkylinkConnection Object if it exists or a new instance if it doesn't exist.

public LifeCycleListener getLifeCycleListener ()

Returns
  • The life cycle listener object.

public Object getLockDisconnectSdp ()

public Object getLockDisconnectSdpCreate ()

public Object getLockDisconnectSdpDrain ()

public Object getLockDisconnectSdpSend ()

public Object getLockDisconnectSdpSet ()

public MediaListener getMediaListener ()

Returns
  • The media listener object

public MessagesListener getMessagesListener ()

Returns
  • The messages listener object.

public RemotePeerListener getRemotePeerListener ()

Returns
  • The remote peer listener object.

public Object getUserData (String remotePeerId)

Retrieves the user defined data object of a peer.

Parameters
remotePeerId The id of the remote peer whose UserData is to be retrieved, or NULL for self.
Returns
  • May be a 'java.lang.String', 'org.json.JSONObject' or 'org.json.JSONArray'.

public UserInfo getUserInfo (String remotePeerId)

Retrieves the UserInfo object of a Peer.

Parameters
remotePeerId The id of the remote peer whose UserInfo is to be retrieved, or NULL for self.
Returns
  • UserInfo

public void init (String appKey, SkylinkConfig config, Context context)

Creates a new SkylinkConnection object with the specified parameters.

Parameters
appKey The App key from the Skylink Developer Console
config The SkylinkConfig object to configure the type of call.
context The application context

public void lockRoom ()

Locks the room if its not already locked

public void muteLocalAudio (boolean isMuted)

Mutes the local user's audio and notifies all the peers in the room.

Parameters
isMuted Flag that specifies whether audio should be mute

public void muteLocalVideo (boolean isMuted)

Mutes the local user's video and notifies all the peers in the room.

Parameters
isMuted Flag that specifies whether video should be mute

public void restartConnection (String remotePeerId)

Restarts a connection with a specific peer or all connections if remotePeerId is null

Parameters
remotePeerId Id of the remote peer to whom we will restart a message. Use 'null' if the message is to be sent to all our remote peers in the room.

public void sendData (String remotePeerId, byte[] data)

Sends a byte array to a specified remotePeer or to all participants of the room if the remotePeerId is null

Parameters
remotePeerId remotePeerID of a specified peer
data Array of bytes

public void sendFileTransferPermissionRequest (String remotePeerId, String fileName, String filePath)

Sends request(s) to share file with a specific remote peer or to all remote peers in a direct peer to peer manner in the same room.

Parameters
remotePeerId The id of the remote peer to send the file to. Use 'null' if the file is to be sent to all our remote peers in the room.
fileName The name of the file that is to be shared.
filePath The absolute path of the file in the filesystem

public void sendFileTransferPermissionResponse (String remotePeerId, String filePath, boolean isPermitted)

Call this method to accept or reject the file share request from a remote peer.

Parameters
remotePeerId The id of the remote peer that requested to share with us a file.
filePath The absolute path of the file where we want it to be saved.
isPermitted Whether permission was granted for the file share to proceed.

public void sendLocalUserData (Object userData)

Sends local user data related to oneself, to all remote peers in our room.

Parameters
userData User defined data relating to the peer. May be a 'java.lang.String', 'org.json.JSONObject' or 'org.json.JSONArray'.

public void sendP2PMessage (String remotePeerId, Object message)

Sends a user defined message to a specific remote peer or to all remote peers in a direct peer to peer manner.

Parameters
remotePeerId Id of the remote peer to whom we will send a message. Use 'null' if the message is to be sent to all our remote peers in the room.
message User defined data. May be a 'java.lang.String', 'org.json.JSONObject' or 'org.json.JSONArray'.
Throws
SkylinkException if the system was unable to send the message.

public void sendServerMessage (String remotePeerId, Object message)

Sends a user defined message to a specific remote peer or to all remote peers via a server.

Parameters
remotePeerId Id of the remote peer to whom we will send a message. Use 'null' if the message is to be broadcast to all remote peers in the room.
message User defined data. May be a 'java.lang.String', 'org.json.JSONObject' or 'org.json.JSONArray'.

public void setDataTransferListener (DataTransferListener dataTransferListener)

Sets the specified data transfer listener object.

Parameters
dataTransferListener The data transfer listener object that will receive callbacks related to DataTransfer

public void setFileTransferListener (FileTransferListener fileTransferListener)

Sets the specified file transfer listener object.

Parameters
fileTransferListener The file transfer listener object that will receive callbacks related to FileTransfer

public void setLifeCycleListener (LifeCycleListener lifeCycleListener)

Sets the specified life cycle listener object.

Parameters
lifeCycleListener The life cycle listener object that will receive callbacks related to the SDK's Lifecycle.

public void setMediaListener (MediaListener mediaListener)

Sets the specified media listener object that will receive callbacks related to Media Stream.

Callbacks include those for the local user and remote peers.

Parameters
mediaListener The media listener object

public void setMessagesListener (MessagesListener messagesListener)

Sets the specified messages listener object.

Parameters
messagesListener The messages listener object that will receive callbacks related to Message Transmissions.

public void setRemotePeerListener (RemotePeerListener remotePeerListener)

Sets the specified remote peer listener object.

Parameters
remotePeerListener The remote peer listener object that will receive callbacks related to remote Peers.

public boolean switchCamera ()

Call this method to switch between available camera.

Returns
  • True or false based on whether the switch was successful or not.

public void unlockRoom ()

Unlocks the room if its already locked