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 b184425b5..22f490ef5 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java +++ b/app/src/main/java/com/nextcloud/talk/activities/CallActivity.java @@ -76,7 +76,6 @@ import com.nextcloud.talk.models.json.generic.GenericOverall; import com.nextcloud.talk.models.json.participants.Participant; import com.nextcloud.talk.models.json.participants.ParticipantsOverall; import com.nextcloud.talk.models.json.signaling.DataChannelMessage; -import com.nextcloud.talk.models.json.signaling.DataChannelMessageNick; import com.nextcloud.talk.models.json.signaling.NCMessagePayload; import com.nextcloud.talk.models.json.signaling.NCSignalingMessage; import com.nextcloud.talk.models.json.signaling.Signaling; @@ -2176,12 +2175,12 @@ public class CallActivity extends CallBaseActivity { } private void startSendingNick() { - DataChannelMessageNick dataChannelMessage = new DataChannelMessageNick(); + DataChannelMessage dataChannelMessage = new DataChannelMessage(); dataChannelMessage.setType("nickChanged"); - HashMap nickChangedPayload = new HashMap<>(); + Map nickChangedPayload = new HashMap<>(); nickChangedPayload.put("userid", conversationUser.getUserId()); nickChangedPayload.put("name", conversationUser.getDisplayName()); - dataChannelMessage.setPayload(nickChangedPayload); + dataChannelMessage.setPayloadMap(nickChangedPayload); for (PeerConnectionWrapper peerConnectionWrapper : peerConnectionWrapperList) { if (peerConnectionWrapper.isMCUPublisher()) { Observable @@ -2196,7 +2195,7 @@ public class CallActivity extends CallBaseActivity { @Override public void onNext(@io.reactivex.annotations.NonNull Long aLong) { - peerConnectionWrapper.sendNickChannelData(dataChannelMessage); + peerConnectionWrapper.sendChannelData(dataChannelMessage); } @Override diff --git a/app/src/main/java/com/nextcloud/talk/models/json/signaling/DataChannelMessage.kt b/app/src/main/java/com/nextcloud/talk/models/json/signaling/DataChannelMessage.kt index 1024afc0f..b0ab14457 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/signaling/DataChannelMessage.kt +++ b/app/src/main/java/com/nextcloud/talk/models/json/signaling/DataChannelMessage.kt @@ -34,10 +34,15 @@ import kotlinx.android.parcel.TypeParceler data class DataChannelMessage( @JsonField(name = ["type"]) var type: String? = null, + /** Can be String or Map + * Use only for received messages */ @JsonField(name = ["payload"]) - var payload: Any? = null + var payload: Any? = null, + /** Use only to send messages */ + @JsonField(name = ["payload"]) + var payloadMap: Map? = null ) : Parcelable { // This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject' - constructor() : this(null, null) + constructor() : this(null, null, null) constructor(type: String) : this(type, null) } diff --git a/app/src/main/java/com/nextcloud/talk/models/json/signaling/DataChannelMessageNick.kt b/app/src/main/java/com/nextcloud/talk/models/json/signaling/DataChannelMessageNick.kt deleted file mode 100644 index 652106fa0..000000000 --- a/app/src/main/java/com/nextcloud/talk/models/json/signaling/DataChannelMessageNick.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Nextcloud Talk application - * - * @author Mario Danic - * @author Andy Scherzinger - * Copyright (C) 2022 Andy Scherzinger - * Copyright (C) 2017 Mario Danic - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.nextcloud.talk.models.json.signaling - -import android.os.Parcelable -import com.bluelinelabs.logansquare.annotation.JsonField -import com.bluelinelabs.logansquare.annotation.JsonObject -import java.util.HashMap -import kotlinx.android.parcel.Parcelize - -@Parcelize -@JsonObject -data class DataChannelMessageNick( - @JsonField(name = ["type"]) - var type: String? = null, - @JsonField(name = ["payload"]) - var payload: HashMap? = null -) : Parcelable { - // This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject' - constructor() : this(null, null) -} diff --git a/app/src/main/java/com/nextcloud/talk/webrtc/PeerConnectionWrapper.java b/app/src/main/java/com/nextcloud/talk/webrtc/PeerConnectionWrapper.java index e5bea1847..d55b85d24 100644 --- a/app/src/main/java/com/nextcloud/talk/webrtc/PeerConnectionWrapper.java +++ b/app/src/main/java/com/nextcloud/talk/webrtc/PeerConnectionWrapper.java @@ -33,7 +33,6 @@ import com.nextcloud.talk.application.NextcloudTalkApplication; import com.nextcloud.talk.events.MediaStreamEvent; import com.nextcloud.talk.events.PeerConnectionEvent; import com.nextcloud.talk.models.json.signaling.DataChannelMessage; -import com.nextcloud.talk.models.json.signaling.DataChannelMessageNick; import com.nextcloud.talk.models.json.signaling.NCIceCandidate; import com.nextcloud.talk.models.json.signaling.NCMessagePayload; import com.nextcloud.talk.models.json.signaling.NCSignalingMessage; @@ -203,18 +202,6 @@ public class PeerConnectionWrapper { } } - public void sendNickChannelData(DataChannelMessageNick dataChannelMessage) { - ByteBuffer buffer; - if (dataChannel != null) { - try { - buffer = ByteBuffer.wrap(LoganSquare.serialize(dataChannelMessage).getBytes()); - dataChannel.send(new DataChannel.Buffer(buffer, false)); - } catch (IOException e) { - Log.d(TAG, "Failed to send channel data, attempting regular " + dataChannelMessage); - } - } - } - public void sendChannelData(DataChannelMessage dataChannelMessage) { ByteBuffer buffer; if (dataChannel != null) {