Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2017-11-15 22:41:35 +01:00
parent 3b447ee7d5
commit 35051828e4
3 changed files with 25 additions and 17 deletions

View file

@ -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', {

View file

@ -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<String> 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<GenericOverall>() {
@Override
@ -685,12 +699,6 @@ public class CallActivity extends AppCompatActivity {
}
});
} catch (IOException exception) {
Log.d(TAG, exception.getLocalizedMessage());
}
}

View file

@ -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<GenericOverall> sendSignalingMessages(@Header("Authorization") String authorization, @Url String url,
@Body List<String> message);
@Body String message);
/*
Server URL is: baseUrl + ocsApiVersion + spreedApiVersion + /signaling