diff --git a/app/build.gradle b/app/build.gradle index 426822a4d..5378806d4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -138,7 +138,8 @@ dependencies { implementation 'com.yarolegovich:lovelyinput:1.0.2' implementation 'com.yarolegovich:mp:1.0.8' - compile 'ru.alexbykov:nopermission:1.1.1' + implementation 'ru.alexbykov:nopermission:1.1.1' + implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.7' testImplementation 'junit:junit:4.12' androidTestImplementation ('com.android.support.test.espresso:espresso-core:3.0.1', { diff --git a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java index ba54a47f3..06a896dbe 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java +++ b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java @@ -53,6 +53,7 @@ import com.nextcloud.talk.events.SessionDescriptionSendEvent; import com.nextcloud.talk.persistence.entities.UserEntity; import com.nextcloud.talk.webrtc.PeerConnectionWrapper; +import org.apache.commons.lang3.StringEscapeUtils; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; @@ -488,7 +489,8 @@ public class CallActivity extends AppCompatActivity { if (sessionId.compareTo(callSession) < 0) { PeerConnectionWrapper connectionWrapper = alwaysGetPeerConnectionWrapperForSessionId(sessionId, false); - connectionWrapper.getPeerConnection().createAnswer(connectionWrapper.getMagicSdpObserver(), sdpConstraints); + connectionWrapper.getPeerConnection().createOffer(connectionWrapper.getMagicSdpObserver(), + sdpConstraints); } else { Log.d(TAG, "Waiting for offer"); } @@ -632,7 +634,7 @@ public class CallActivity extends AppCompatActivity { } @Subscribe(threadMode = ThreadMode.BACKGROUND) - public void onMessageEvent(SessionDescriptionSendEvent sessionDescriptionSend) { + public void onMessageEvent(SessionDescriptionSendEvent sessionDescriptionSend) throws IOException { Log.d("MARIO_123", "SENDING " + sessionDescriptionSend.getType()); String credentials = ApiHelper.getCredentials(userEntity.getUsername(), userEntity.getToken()); NCMessageWrapper ncMessageWrapper = new NCMessageWrapper(); @@ -656,13 +658,25 @@ public class CallActivity extends AppCompatActivity { ncSignalingMessage.setPayload(ncMessagePayload); ncMessageWrapper.setSignalingMessage(ncSignalingMessage); - List awesomeJson = new ArrayList<>(); - try { - awesomeJson.add(LoganSquare.serialize(ncMessageWrapper)); - Log.d("MARIO_JSON", LoganSquare.serialize(ncMessageWrapper)); - ncApi.sendSignalingMessages(credentials, ApiHelper.getUrlForSignaling(userEntity.getBaseUrl()), - awesomeJson) + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("["); + stringBuilder.append("{"); + stringBuilder.append("\"fn\":\""); + stringBuilder.append(StringEscapeUtils.escapeEcmaScript(LoganSquare.serialize(ncMessageWrapper + .getSignalingMessage())) + "\""); + stringBuilder.append(","); + stringBuilder.append("\"sessionId\":"); + stringBuilder.append("\"").append(callSession).append("\""); + stringBuilder.append(","); + stringBuilder.append("\"ev\":\"message\""); + stringBuilder.append("}"); + stringBuilder.append("]"); + + String stringToSend = stringBuilder.toString(); + Log.d("MARIO", stringToSend); + ncApi.sendSignalingMessages(credentials, ApiHelper.getUrlForSignaling(userEntity.getBaseUrl()), + stringToSend) .subscribeOn(Schedulers.newThread()) .subscribe(new Observer() { @Override @@ -685,12 +699,6 @@ public class CallActivity extends AppCompatActivity { } }); - - } catch (IOException exception) { - Log.d(TAG, exception.getLocalizedMessage()); - } - - } diff --git a/app/src/main/java/com/nextcloud/talk/api/NcApi.java b/app/src/main/java/com/nextcloud/talk/api/NcApi.java index dee8ebc46..f635c1a29 100644 --- a/app/src/main/java/com/nextcloud/talk/api/NcApi.java +++ b/app/src/main/java/com/nextcloud/talk/api/NcApi.java @@ -32,7 +32,6 @@ import com.nextcloud.talk.api.models.json.sharees.ShareesOverall; import com.nextcloud.talk.api.models.json.signaling.SignalingOverall; import com.nextcloud.talk.api.models.json.userprofile.UserProfileOverall; -import java.util.List; import java.util.Map; import io.reactivex.Observable; @@ -168,7 +167,7 @@ public interface NcApi { */ @POST Observable sendSignalingMessages(@Header("Authorization") String authorization, @Url String url, - @Body List message); + @Body String message); /* Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /signaling