Rewrite method to return early

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2024-12-06 04:14:58 +01:00 committed by Marcel Hibbe
parent c222e01095
commit bcd3893e7d
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B

View File

@ -286,13 +286,15 @@ public class PeerConnectionWrapper {
*/ */
public void send(DataChannelMessage dataChannelMessage) { public void send(DataChannelMessage dataChannelMessage) {
DataChannel statusDataChannel = dataChannels.get("status"); DataChannel statusDataChannel = dataChannels.get("status");
if (statusDataChannel != null && dataChannelMessage != null) { if (statusDataChannel == null || dataChannelMessage == null) {
try { return;
ByteBuffer buffer = ByteBuffer.wrap(LoganSquare.serialize(dataChannelMessage).getBytes()); }
statusDataChannel.send(new DataChannel.Buffer(buffer, false));
} catch (Exception e) { try {
Log.d(TAG, "Failed to send channel data, attempting regular " + dataChannelMessage); ByteBuffer buffer = ByteBuffer.wrap(LoganSquare.serialize(dataChannelMessage).getBytes());
} statusDataChannel.send(new DataChannel.Buffer(buffer, false));
} catch (Exception e) {
Log.d(TAG, "Failed to send channel data, attempting regular " + dataChannelMessage);
} }
} }