Safeguards against null

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2018-01-16 11:14:29 +01:00
parent 02c115d49b
commit f1d89ccacb

View File

@ -111,12 +111,13 @@ public class MagicPeerConnectionWrapper {
public void drainIceCandidates() {
if (peerConnection != null) {
for (IceCandidate iceCandidate : iceCandidates) {
peerConnection.addIceCandidate(iceCandidate);
}
iceCandidates = new ArrayList<>();
}
}
public MagicSdpObserver getMagicSdpObserver() {
@ -124,12 +125,14 @@ public class MagicPeerConnectionWrapper {
}
public void addCandidate(IceCandidate iceCandidate) {
if (peerConnection != null) {
if (peerConnection.getRemoteDescription() != null) {
peerConnection.addIceCandidate(iceCandidate);
} else {
iceCandidates.add(iceCandidate);
}
}
}
public void sendChannelData(DataChannelMessage dataChannelMessage) {
ByteBuffer buffer = null;
@ -338,8 +341,10 @@ public class MagicPeerConnectionWrapper {
EventBus.getDefault().post(new SessionDescriptionSendEvent(sessionDescriptionWithPreferredCodec, sessionId,
sessionDescription.type.canonicalForm().toLowerCase(), null));
if (peerConnection != null) {
peerConnection.setLocalDescription(magicSdpObserver, sessionDescriptionWithPreferredCodec);
}
}
@Override
public void onSetSuccess() {