mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 03:59:35 +01:00
Add listener for "reaction" signaling message
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
parent
21ba5d87f0
commit
0a54fd6127
@ -2805,6 +2805,10 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReaction(String reaction) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUnshareScreen() {
|
public void onUnshareScreen() {
|
||||||
endPeerConnection(sessionId, "screen");
|
endPeerConnection(sessionId, "screen");
|
||||||
|
@ -40,6 +40,10 @@ public class CallParticipant {
|
|||||||
callParticipantModel.setRaisedHand(state, timestamp);
|
callParticipantModel.setRaisedHand(state, timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReaction(String reaction) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUnshareScreen() {
|
public void onUnshareScreen() {
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,10 @@ data class NCMessagePayload(
|
|||||||
@JsonField(name = ["state"])
|
@JsonField(name = ["state"])
|
||||||
var state: Boolean? = null,
|
var state: Boolean? = null,
|
||||||
@JsonField(name = ["timestamp"])
|
@JsonField(name = ["timestamp"])
|
||||||
var timestamp: Long? = null
|
var timestamp: Long? = null,
|
||||||
|
@JsonField(name = ["reaction"])
|
||||||
|
var reaction: String? = null
|
||||||
) : Parcelable {
|
) : Parcelable {
|
||||||
// This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
|
// This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
|
||||||
constructor() : this(null, null, null, null, null, null, null)
|
constructor() : this(null, null, null, null, null, null, null, null)
|
||||||
}
|
}
|
||||||
|
@ -93,6 +93,12 @@ class CallParticipantMessageNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void notifyReaction(String sessionId, String reaction) {
|
||||||
|
for (SignalingMessageReceiver.CallParticipantMessageListener listener : getListenersFor(sessionId)) {
|
||||||
|
listener.onReaction(reaction);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized void notifyUnshareScreen(String sessionId) {
|
public synchronized void notifyUnshareScreen(String sessionId) {
|
||||||
for (SignalingMessageReceiver.CallParticipantMessageListener listener : getListenersFor(sessionId)) {
|
for (SignalingMessageReceiver.CallParticipantMessageListener listener : getListenersFor(sessionId)) {
|
||||||
listener.onUnshareScreen();
|
listener.onUnshareScreen();
|
||||||
|
@ -149,6 +149,7 @@ public abstract class SignalingMessageReceiver {
|
|||||||
*/
|
*/
|
||||||
public interface CallParticipantMessageListener {
|
public interface CallParticipantMessageListener {
|
||||||
void onRaiseHand(boolean state, long timestamp);
|
void onRaiseHand(boolean state, long timestamp);
|
||||||
|
void onReaction(String reaction);
|
||||||
void onUnshareScreen();
|
void onUnshareScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -562,6 +563,57 @@ public abstract class SignalingMessageReceiver {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ("reaction".equals(type)) {
|
||||||
|
// Message schema (external signaling server):
|
||||||
|
// {
|
||||||
|
// "type": "message",
|
||||||
|
// "message": {
|
||||||
|
// "sender": {
|
||||||
|
// ...
|
||||||
|
// },
|
||||||
|
// "data": {
|
||||||
|
// "to": #STRING#,
|
||||||
|
// "roomType": "video",
|
||||||
|
// "type": "reaction",
|
||||||
|
// "payload": {
|
||||||
|
// "reaction": #STRING#,
|
||||||
|
// },
|
||||||
|
// "from": #STRING#,
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Message schema (internal signaling server):
|
||||||
|
// {
|
||||||
|
// "type": "message",
|
||||||
|
// "data": {
|
||||||
|
// "to": #STRING#,
|
||||||
|
// "roomType": "video",
|
||||||
|
// "type": "reaction",
|
||||||
|
// "payload": {
|
||||||
|
// "reaction": #STRING#,
|
||||||
|
// },
|
||||||
|
// "from": #STRING#,
|
||||||
|
// },
|
||||||
|
// }
|
||||||
|
|
||||||
|
NCMessagePayload payload = signalingMessage.getPayload();
|
||||||
|
if (payload == null) {
|
||||||
|
// Broken message, this should not happen.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String reaction = payload.getReaction();
|
||||||
|
if (reaction == null) {
|
||||||
|
// Broken message, this should not happen.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
callParticipantMessageNotifier.notifyReaction(sessionId, reaction);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// "unshareScreen" messages are directly sent to the screen peer connection when the internal signaling
|
// "unshareScreen" messages are directly sent to the screen peer connection when the internal signaling
|
||||||
// server is used, and to the room when the external signaling server is used. However, the (relevant) data
|
// server is used, and to the room when the external signaling server is used. However, the (relevant) data
|
||||||
// of the received message ("from" and "type") is the same in both cases.
|
// of the received message ("from" and "type") is the same in both cases.
|
||||||
|
@ -84,6 +84,26 @@ public class SignalingMessageReceiverCallParticipantTest {
|
|||||||
verify(mockedCallParticipantMessageListener, only()).onRaiseHand(true, 4815162342L);
|
verify(mockedCallParticipantMessageListener, only()).onRaiseHand(true, 4815162342L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCallParticipantMessageReaction() {
|
||||||
|
SignalingMessageReceiver.CallParticipantMessageListener mockedCallParticipantMessageListener =
|
||||||
|
mock(SignalingMessageReceiver.CallParticipantMessageListener.class);
|
||||||
|
|
||||||
|
signalingMessageReceiver.addListener(mockedCallParticipantMessageListener, "theSessionId");
|
||||||
|
|
||||||
|
NCSignalingMessage signalingMessage = new NCSignalingMessage();
|
||||||
|
signalingMessage.setFrom("theSessionId");
|
||||||
|
signalingMessage.setType("reaction");
|
||||||
|
signalingMessage.setRoomType("theRoomType");
|
||||||
|
NCMessagePayload messagePayload = new NCMessagePayload();
|
||||||
|
messagePayload.setType("reaction");
|
||||||
|
messagePayload.setReaction("theReaction");
|
||||||
|
signalingMessage.setPayload(messagePayload);
|
||||||
|
signalingMessageReceiver.processSignalingMessage(signalingMessage);
|
||||||
|
|
||||||
|
verify(mockedCallParticipantMessageListener, only()).onReaction("theReaction");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCallParticipantMessageUnshareScreen() {
|
public void testCallParticipantMessageUnshareScreen() {
|
||||||
SignalingMessageReceiver.CallParticipantMessageListener mockedCallParticipantMessageListener =
|
SignalingMessageReceiver.CallParticipantMessageListener mockedCallParticipantMessageListener =
|
||||||
|
Loading…
Reference in New Issue
Block a user