Логичная структура пакетов без магических чисел

This commit is contained in:
RoyceDa
2026-03-16 17:06:25 +02:00
parent ce404188d4
commit a4346679e7
5 changed files with 53 additions and 13 deletions

View File

@@ -3,6 +3,8 @@ package io.g365sfu;
import java.nio.ByteBuffer;
import java.util.HashSet;
import io.g365sfu.net.Outgoing;
/**
* Это комната для звонков, она может быть как для двоих участников, так и для групповых звонков.
* Комната содержит в себе информацию о том, на каком она SFU сервере, какой у нее ID, кто в ней участвует.
@@ -77,7 +79,7 @@ public class Room {
/**
* 0x03 - SDP offer
*/
buffer.put((byte)0x03);
buffer.put(Outgoing.SDP_OFFER_RETRANSLATE);
buffer.putInt(this.roomId.getBytes().length);
buffer.put(this.roomId.getBytes());
buffer.putInt(participantId.getBytes().length);
@@ -111,7 +113,7 @@ public class Room {
/**
* 0x06 - ICE кандидат
*/
buffer.put((byte)0x06);
buffer.put(Outgoing.ICE_CANDIDATE_RETRANSLATE);
buffer.putInt(this.roomId.getBytes().length);
buffer.put(this.roomId.getBytes());
buffer.putInt(participantId.getBytes().length);
@@ -145,7 +147,7 @@ public class Room {
/**
* 0x07 - SDP answer
*/
buffer.put((byte)0x07);
buffer.put(Outgoing.SDP_ANSWER_RETRANSLATE);
buffer.putInt(this.roomId.getBytes().length);
buffer.put(this.roomId.getBytes());
buffer.putInt(participantId.getBytes().length);