Discord/TS-Teilnehmer als Mitglieder in der Voicechat-Gruppenanzeige (mit Sprech-Symbol), Actionbar entfernt
This commit is contained in:
1 parent
d5c181a224
commit
e2546ad982
17 files changed
+250
-150
No files matched your search
@@ -28,6 +28,9 @@ public sealed interface Message {
|
||||
/** Bridge → Plugin: Chat-Hinweis an alle in der Gruppe, z. B. wer dazugekommen ist. */
|
||||
record Notice(String room, String text) implements Message {}
|
||||
|
||||
/** Bridge → Plugin: wer aus Discord/TeamSpeak gerade spricht (für die Actionbar), je "Name|Kürzel". */
|
||||
record Speakers(String room, List<String> names) implements Message {}
|
||||
/**
|
||||
* Bridge → Plugin: wer aus Discord/TeamSpeak im Raum ist. {@code id} ist dieselbe UUID wie die
|
||||
* {@code source} seines Audios, damit der Voicechat-Client das Sprech-Symbol zuordnen kann.
|
||||
*/
|
||||
record Participants(String room, List<Member> members) implements Message {}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import java.util.UUID;
|
||||
|
||||
public final class Protocol {
|
||||
/** Bei inkompatiblen Änderungen am Format hochzählen. */
|
||||
public static final int VERSION = 2;
|
||||
public static final int VERSION = 3;
|
||||
public static final int DEFAULT_PORT = 24470;
|
||||
public static final int MAX_DATAGRAM = 2048;
|
||||
|
||||
@@ -22,7 +22,7 @@ public final class Protocol {
|
||||
private static final byte ROOMS = 2;
|
||||
private static final byte AUDIO = 3;
|
||||
private static final byte NOTICE = 4;
|
||||
private static final byte SPEAKERS = 5;
|
||||
private static final byte PARTICIPANTS = 5;
|
||||
|
||||
private Protocol() {}
|
||||
|
||||
@@ -66,11 +66,14 @@ public final class Protocol {
|
||||
out.writeUTF(notice.room());
|
||||
out.writeUTF(notice.text());
|
||||
}
|
||||
case Message.Speakers speakers -> {
|
||||
out.writeByte(SPEAKERS);
|
||||
out.writeUTF(speakers.room());
|
||||
out.writeShort(speakers.names().size());
|
||||
for (String name : speakers.names()) out.writeUTF(name);
|
||||
case Message.Participants participants -> {
|
||||
out.writeByte(PARTICIPANTS);
|
||||
out.writeUTF(participants.room());
|
||||
out.writeShort(participants.members().size());
|
||||
for (Message.Member member : participants.members()) {
|
||||
writeUuid(out, member.id());
|
||||
out.writeUTF(member.name());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
@@ -107,12 +110,12 @@ public final class Protocol {
|
||||
}
|
||||
case AUDIO -> new Message.Audio(in.readUTF(), readUuid(in), in.readAllBytes());
|
||||
case NOTICE -> new Message.Notice(in.readUTF(), in.readUTF());
|
||||
case SPEAKERS -> {
|
||||
case PARTICIPANTS -> {
|
||||
String room = in.readUTF();
|
||||
int size = in.readUnsignedShort();
|
||||
List<String> names = new ArrayList<>(size);
|
||||
for (int i = 0; i < size; i++) names.add(in.readUTF());
|
||||
yield new Message.Speakers(room, names);
|
||||
List<Message.Member> members = new ArrayList<>(size);
|
||||
for (int i = 0; i < size; i++) members.add(new Message.Member(readUuid(in), in.readUTF()));
|
||||
yield new Message.Participants(room, members);
|
||||
}
|
||||
default -> throw new IOException("Unbekannter Nachrichtentyp " + type);
|
||||
};
|
||||
|
||||
@@ -41,11 +41,12 @@ class ProtocolTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void noticeAndSpeakers() throws IOException {
|
||||
void noticeAndParticipants() throws IOException {
|
||||
Message.Notice notice = new Message.Notice("crosstalk-1", "Anna (Discord) ist dazugekommen.");
|
||||
assertEquals(notice, roundTrip(notice));
|
||||
Message.Speakers speakers = new Message.Speakers("crosstalk-1", List.of("Anna (Discord)", "Bob (TeamSpeak)"));
|
||||
assertEquals(speakers, roundTrip(speakers));
|
||||
Message.Participants participants = new Message.Participants("crosstalk-1",
|
||||
List.of(new Message.Member(UUID.randomUUID(), "Anna [Discord]")));
|
||||
assertEquals(participants, roundTrip(participants));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user