Introduce authentication framework with AuthConfig, AuthGate, and Authenticator classes, alongside comprehensive tests for rules, modes, and schemes.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package dev.coph.nextusweb.server.websocket;
|
||||
|
||||
import dev.coph.nextusweb.server.json.JsonMapper;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.group.ChannelGroup;
|
||||
import io.netty.channel.group.DefaultChannelGroup;
|
||||
import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame;
|
||||
@@ -102,8 +103,9 @@ public final class WebSocketGroup {
|
||||
public WebSocketGroup broadcastJson(Object value) {
|
||||
try {
|
||||
byte[] bytes = JsonMapper.MAPPER.writeValueAsBytes(value);
|
||||
String text = new String(bytes, java.nio.charset.StandardCharsets.UTF_8);
|
||||
channels.writeAndFlush(new TextWebSocketFrame(text));
|
||||
// Build the text frame straight from the serialized UTF-8 bytes; the channel group
|
||||
// duplicates the payload per recipient, so no String round-trip re-encode is needed.
|
||||
channels.writeAndFlush(new TextWebSocketFrame(Unpooled.wrappedBuffer(bytes)));
|
||||
} catch (JacksonException e) {
|
||||
throw new RuntimeException("JSON serialization failed", e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user