Blog

iris

ConnectyCube API for message search on the server

Posted by iris on February 19, 2019

Hi,

We are happy to let you know about our new feature – API for searching messages on the server!

This feature allows searching messages and chats in chat history on the server by a word or phrase.

Feel free to check our documentation for more details.

SDKs with this feature added shall follow soon.

Keep an eye for further updates.

 

Your feedback is always welcome!

iris

ConnectyCube solutions for video calling and difference in approaches

Posted by iris on February 15, 2019

ConnectyCube Video Calling API is built on top of WebRTC technology and allows adding audio and video calling features into your native iOS, Android and hybrid mobile and web JS applications.

There are two approaches for WebRTC audio/video calls implementation in ConnectyCube:

Client-side (P2P (Mesh) scheme) 

WebRTC technology sets peer-to-peer connection between all callers, which completely excludes ConnectyCube server from participating in passing media streams during the call.

In multi-person conversation, WebRTC sets so called “full-mesh connection” with multiple P2P connections set simultaneously.
The only role ConnectyCube server plays in this case is establishing the connection between the participants before the call (signaling).

Multiparty Video calls (SFU) server-side implementation.

This solution relies on the same WebRTC standards, but it implies deploying a separate media server called SFU (Selective Forwarding Unit) to realize stable conversation with more participants.
SFU server processes media stream during video calls.

Pros and Cons

MESH SFU
Pros
  1. Low latency for 1-1 connection
  2. No server cost
  1. Up to 15 users on the call.
  2. One outgoing (upload) stream, so less device loading.
  3. It is possible to have video streaming.
  4. Possible to manage participants during ongoing call.
  5. It is possible to have server-side audio/video recording
Cons
  1. Doesn’t scale for more than 5 users on the call due to high traffic and device overloading.
  2. Doesn’t support video streaming (one-way video streaming).
  3. There is no way to manage participants during ongoing call
  1. Higher latency for 1-1 connection comparing with client side solution
  2. Server cost (additional AWS hosting of EC2 instance and ConnectyCube fee for Multiparty Video calls server setup)

 

Signaling

Signaling takes place before audio/video call is established between the users.

There is a difference in approach used by video solutions to give a call:

Standard WebRTC solution

Standard WebRTC solution uses signaling messages to initiate, accept, reject and hang up a call.
All video chat signaling messages have type="headline" and an extra parameter <moduleIdentifier>...</moduleIdentifier>. So you can detect the video chat signaling message by these two parameters.
Check this guide for more details.

SFU solution

With SFU solution all users are joining the room for the call and a notification about incoming call is not sent by default.
However, you can use system messages to give a call with SFU solution similarly to the standard WebRTC solution as follows:

a) On UI you need to set system notifications to be sent for incoming calls. For example, Android system notifications can be sent as follows:

ConnectycubeChatMessage systemMessage = new ConnectycubeChatMessage();
systemMessage.setRecipientId(58672);
systemMessage.setProperty("param1", "value1");
systemMessage.setProperty("param2", "value2");
systemMessage.setBody("some text");
try {
systemMessagesManager.sendSystemMessage(systemMessage);
} catch (SmackException.NotConnectedException e) {
e.printStackTrace();
}

b) You need also to set a listener to listen to such notifications on recipient’s side. Here is an example from Android documentation:

SystemMessagesManager systemMessagesManager = ConnectycubeChatService.getInstance().getSystemMessagesManager();
SystemMessageListener systemMessageListener = new SystemMessageListener() {
@Override
public void processMessage(ConnectycubeChatMessage message) {
}
@Override
public void processError(ChatException exception, ConnectycubeChatMessage message) {
}
};
systemMessagesManager.addSystemMessageListener(systemMessageListener);

c) Upon receiving such system notification you can set a pop-up window about incoming call to appear with accept/reject buttons.

d) Once Accept button is clicked the user should join video room. Check the following example from Android documentation:

ConferenceRole conferenceRole = asListenerRole ? ConferenceRole.LISTENER : ConferenceRole.PUBLISHER;
currentSession.joinDialog(dialogID, conferenceRole, new ConferenceEntityCallback<ArrayList> {
...
});

Note:
If you subscribe as listener, you’ll get audio/video streams from publishers, but will not publish your own video and audio streams.

e) For rejecting a call you can set the pop-up window to be closed on UI without joining the room.
If you need, you can add a system notification to be sent to the call initiator notifying him that the incoming call was rejected.

 

Other differences

Adding participants:

Standard WebRTC solution

Standard WebRTC peer-to-peer solution allows adding participants at the call initiation only due to limitations of WebRTC mesh scheme. Once the call connection is established, there is no possibility to add/remove participants without interrupting the call.

SFU solution

SFU solution allows adding/removing participants during ongoing call. In order to join the call a user should be listed in the Occupants_ID list of a room/chat. Here you can find an example for joining video room on Android.

 

Re-joining an ongoing call:

Standard WebRTC solution

Standard WebRTC peer-to-peer solution does not allow re-joining due to limitations of this approach. In case one of the users disconnects, the call stops and it is necessary to establish the call again.

SFU solution

SFU solution allows re-joining the ongoing call in case the user has lost connection due to temporary internet connectivity issues or reloaded the page, for example. You can implement this function as follows (example from Web):

Option 1:

a) Check that the call is still in progress:

client.listOnlineParticipants(chatDialogId, {
success: function(participants){
},
error: function(error){
}
});

b) Then check that you are not in the call:

client.currentDialogId

Note:
If it returns null, then there is no dialog.
Such check should work well if we have re-loaded the page.

c) If the call is on and the user is not in that call, you can show re-join button on UI.

Note:
After losing connection UserID exists on server about 30 sec, so after a while you can join the room successfully again.

 

Option 2:

Also you can set re-join button to be shown if error about internet connection being lost is triggered in the app.

Such case you can try handling via iceState callback and if state is closed for all users and you, this means that everything is disconnected.

In that case you need to close the call and initialize it again programmatically.

And you need to show Re-join button in such case.

 

Audio/video recording:

Standard WebRTC solution

Standard WebRTC approach does not allow using server-side recording since server does not participate in passing media streams. So, the only way is to use client-side recording (recording is saved on the local device only). Here is an example for iOS client-side audio/video recording.

SFU solution

SFU solution allows using server-side recording. ConnectyCube provides this option together with SFU solution. In this case the recordings are saved on the server.

 

Have any questions?

Feel free to contact us.

Charlie

ConnectyCube ReactNative files upload code sample release

Posted by Charlie on January 21, 2019

Hi!

We are glad to let you know about the release of our ReactNative sample!

Project contains the following features implemented:

  • User login to ConnectyCube platform
  • Possibility to make photo via device camera
  • Possibility to pick images from device gallery
  • Upload the chosen image file to ConnectyCube storage

Live demo
https://expo.io/@ccvlad/RNUploadFiles

Sample src code
https://github.com/ConnectyCube/connectycube-js-samples/tree/master/RNUploadFiles

Charlie

New Android SDK v1.6.0

Posted by Charlie on December 26, 2018

Hi!

We are happy to release a great amount of updates with our new Android SDK v1.6.0!

Chat module

Updated

In ConnectycubeChatDialog:

  • renamed dialog type ConnectycubeDialogType.PUBLIC_GROUP (type 1) to ConnectycubeDialogType.BROADCAST

Removed

In ConnectycubeChatDialog:

  • DiscussionHistory property from join(history) and join(history, callback) – Now join() or join(callback)

Updated

In ConnectycubeChatMessage:

  • added viewsCount field (broadcast and public dialog only)
  • now saveToHistory = true by default (setSaveToHistory(false);)

Deprecated

In ConnectycubeChatService:

  • setConfigurationBuilder() – Now setConnectionFabric().
setConnectionFabric(new TcpChatConnectionFabric(new TcpConfigurationBuilder().setUseTls(false))); //TLS true by default

Core module

Updated

In ConnectycubeUser:

  • added avatar field

Storage module

Removed

In ConnectycubeStorage:

  • tags property from uploadFileTask(File file, boolean publicAccess, String tags) – Now uploadFileTask(File file, boolean publicAccess)

Push module

Removed

  • pushnotifications TYPE GCM, Now FCM type only is supported.
 // In AndroidManifest no need to set android:value="FCM", just:
        <meta-data android:name="com.connectycube.pushnotifications.SENDER_ID" android:value="@string/sender_id" />
        <meta-data android:name="com.connectycube.pushnotifications.ENVIRONMENT" android:value="DEVELOPMENT" />
  • FcmPushInstanceIDService service with onTokenRefresh(), which was deprecated by Firebase.
// FcmPushInstanceIDService from AndroidManifest must be removed!
        <service
            android:name="com.connectycube.pushnotifications.services.fcm.FcmPushInstanceIDService"
...
        </service>

Updated

In FcmPushListenerService:

  • added onNewToken() instead of onTokenRefresh from FcmPushInstanceIDService;
  • all firebase and play-services dependencies to the latest versions

Deprecated

In FcmPushListenerService:

  • sendPushMessage(Map data, String from, String message) – Now use more detailed sendPushMessage(Map data, String message, String messageId, String dialogId, String userId).

Video module

Updated

In RTCSession:

  • added isAudioCall() – to check call Type

Deprecated

  • RTCClientVideoTracksCallbacks – now RTCClientVideoTracksCallback

Other

Fixed

  • parsing ConnectycubeUserSessionDetails
  • handling Unauthorized exception when restore session with deleted user

New SDK is available on our GitHub page.