mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-17 09:45:02 +01:00
Additional logging
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
ef2d1b8c92
commit
7d44805c9e
@ -21,9 +21,11 @@
|
||||
|
||||
package com.nextcloud.talk.webrtc;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.Nullable;
|
||||
import autodagger.AutoInjector;
|
||||
import com.bluelinelabs.logansquare.LoganSquare;
|
||||
import com.nextcloud.talk.R;
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||
@ -33,15 +35,18 @@ import com.nextcloud.talk.events.SessionDescriptionSendEvent;
|
||||
import com.nextcloud.talk.events.WebSocketCommunicationEvent;
|
||||
import com.nextcloud.talk.models.json.signaling.DataChannelMessage;
|
||||
import com.nextcloud.talk.models.json.signaling.NCIceCandidate;
|
||||
import com.nextcloud.talk.utils.LoggingUtils;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.webrtc.*;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@AutoInjector(NextcloudTalkApplication.class)
|
||||
public class MagicPeerConnectionWrapper {
|
||||
private static String TAG = "MagicPeerConnectionWrapper";
|
||||
private List<IceCandidate> iceCandidates = new ArrayList<>();
|
||||
@ -62,12 +67,17 @@ public class MagicPeerConnectionWrapper {
|
||||
private boolean isMCUPublisher;
|
||||
private String videoStreamType;
|
||||
|
||||
@Inject
|
||||
Context context;
|
||||
|
||||
public MagicPeerConnectionWrapper(PeerConnectionFactory peerConnectionFactory,
|
||||
List<PeerConnection.IceServer> iceServerList,
|
||||
MediaConstraints mediaConstraints,
|
||||
String sessionId, String localSession, @Nullable MediaStream mediaStream,
|
||||
boolean isMCUPublisher, boolean hasMCU, String videoStreamType) {
|
||||
|
||||
NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this);
|
||||
|
||||
this.localMediaStream = mediaStream;
|
||||
this.videoStreamType = videoStreamType;
|
||||
|
||||
@ -231,6 +241,8 @@ public class MagicPeerConnectionWrapper {
|
||||
data.get(bytes);
|
||||
String strData = new String(bytes);
|
||||
Log.d(TAG, "Got msg: " + strData + " over " + TAG + " " + sessionId);
|
||||
LoggingUtils.writeLogEntryToFile(context,
|
||||
"Got msg: " + strData + " over " + peerConnection.hashCode() + " " + sessionId);
|
||||
|
||||
try {
|
||||
DataChannelMessage dataChannelMessage = LoganSquare.parse(strData, DataChannelMessage.class);
|
||||
@ -284,6 +296,9 @@ public class MagicPeerConnectionWrapper {
|
||||
|
||||
@Override
|
||||
public void onIceConnectionChange(PeerConnection.IceConnectionState iceConnectionState) {
|
||||
LoggingUtils.writeLogEntryToFile(context,
|
||||
"iceConnectionChangeTo: " + iceConnectionState.name() + " over " + peerConnection.hashCode() + " " + sessionId);
|
||||
|
||||
if (iceConnectionState.equals(PeerConnection.IceConnectionState.CONNECTED)) {
|
||||
/*EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
|
||||
.PEER_CONNECTED, sessionId, null, null));*/
|
||||
@ -363,11 +378,16 @@ public class MagicPeerConnectionWrapper {
|
||||
@Override
|
||||
public void onCreateFailure(String s) {
|
||||
Log.d(TAG, s);
|
||||
LoggingUtils.writeLogEntryToFile(context,
|
||||
"SDPObserver createFailure: " + s + " over " + peerConnection.hashCode() + " " + sessionId);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetFailure(String s) {
|
||||
Log.d(TAG, s);
|
||||
LoggingUtils.writeLogEntryToFile(context,
|
||||
"SDPObserver setFailure: " + s + " over " + peerConnection.hashCode() + " " + sessionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -33,6 +33,7 @@ import com.nextcloud.talk.models.database.UserEntity;
|
||||
import com.nextcloud.talk.models.json.signaling.NCMessageWrapper;
|
||||
import com.nextcloud.talk.models.json.signaling.NCSignalingMessage;
|
||||
import com.nextcloud.talk.models.json.websocket.*;
|
||||
import com.nextcloud.talk.utils.LoggingUtils;
|
||||
import com.nextcloud.talk.utils.MagicMap;
|
||||
import com.nextcloud.talk.utils.singletons.MerlinTheWizard;
|
||||
import com.novoda.merlin.Endpoint;
|
||||
@ -143,6 +144,9 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
||||
public void onMessage(WebSocket webSocket, String text) {
|
||||
if (webSocket == internalWebSocket) {
|
||||
Log.d(TAG, "Receiving : " + text);
|
||||
LoggingUtils.writeLogEntryToFile(context,
|
||||
"WebSocket " + webSocket.hashCode() + " receiving: " + text);
|
||||
|
||||
try {
|
||||
BaseWebSocketMessage baseWebSocketMessage = LoganSquare.parse(text, BaseWebSocketMessage.class);
|
||||
String messageType = baseWebSocketMessage.getType();
|
||||
@ -166,6 +170,8 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
||||
case "error":
|
||||
ErrorOverallWebSocketMessage errorOverallWebSocketMessage = LoganSquare.parse(text, ErrorOverallWebSocketMessage.class);
|
||||
if (("no_such_session").equals(errorOverallWebSocketMessage.getErrorWebSocketMessage().getCode())) {
|
||||
LoggingUtils.writeLogEntryToFile(context,
|
||||
"WebSocket " + webSocket.hashCode() + " resumeID " + resumeId + " expired");
|
||||
resumeId = "";
|
||||
restartWebSocket();
|
||||
} else if (("hello_expected").equals(errorOverallWebSocketMessage.getErrorWebSocketMessage().getCode())) {
|
||||
@ -250,7 +256,9 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
||||
break;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Failed to WebSocket message");
|
||||
LoggingUtils.writeLogEntryToFile(context,
|
||||
"WebSocket " + webSocket.hashCode() + " IOException: " + e.getMessage());
|
||||
Log.e(TAG, "Failed to recognize WebSocket message");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -263,11 +271,15 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
||||
@Override
|
||||
public void onClosing(WebSocket webSocket, int code, String reason) {
|
||||
Log.d(TAG, "Closing : " + code + " / " + reason);
|
||||
LoggingUtils.writeLogEntryToFile(context,
|
||||
"WebSocket " + webSocket.hashCode() + " Closing: " + reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(WebSocket webSocket, Throwable t, Response response) {
|
||||
Log.d(TAG, "Error : " + t.getMessage());
|
||||
LoggingUtils.writeLogEntryToFile(context,
|
||||
"WebSocket " + webSocket.hashCode() + " onFailure: " + t.getMessage());
|
||||
closeWebSocket(webSocket);
|
||||
restartWebSocket();
|
||||
}
|
||||
@ -302,6 +314,8 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
||||
internalWebSocket.send(message);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LoggingUtils.writeLogEntryToFile(context,
|
||||
"WebSocket sendCalLMessage: " + e.getMessage() + "\n" + ncMessageWrapper.toString());
|
||||
Log.e(TAG, "Failed to serialize signaling message");
|
||||
}
|
||||
}
|
||||
@ -321,6 +335,8 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
||||
internalWebSocket.send(message);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LoggingUtils.writeLogEntryToFile(context,
|
||||
"WebSocket requestOfferForSessionIdWithType: " + e.getMessage() + "\n" + sessionIdParam + " " + roomType);
|
||||
Log.e(TAG, "Failed to offer request");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user