Class SseSerializer
java.lang.Object
dev.tachyonmcp.core.transport.netty.sse.SseSerializer
Serializes an outbound
SseEvent into its text/event-stream wire framing, writing
straight into a pooled buffer from alloc. Keeps the framing (a transport concern) out of
SseEvent so the mcp.server model stays free of Netty types, and avoids the
intermediate String a format() helper would allocate on the hot write path.-
Method Summary
Modifier and TypeMethodDescriptionstatic io.netty.buffer.ByteBufEncodeseventasid: …\nevent: …\ndata: …\n\n, splitting multi-line data into onedata:line per\n(matching the SSE spec).static io.netty.buffer.ByteBufEncodes a rawbodyas amessageevent, omitting theid:field whenwireIdisnull, with onedata:field per body line.
-
Method Details
-
encode
public static io.netty.buffer.ByteBuf encode(io.netty.buffer.ByteBufAllocator alloc, SseEvent event) Encodeseventasid: …\nevent: …\ndata: …\n\n, splitting multi-line data into onedata:line per\n(matching the SSE spec). The returned buffer is owned by the caller and must be released after the write completes. -
encode
public static io.netty.buffer.ByteBuf encode(io.netty.buffer.ByteBufAllocator alloc, @Nullable String wireId, byte @Nullable [] body) Encodes a rawbodyas amessageevent, omitting theid:field whenwireIdisnull, with onedata:field per body line. Anullor empty body produces one emptydata:field. Encoding writes straight into a single pooled buffer (noStringdecode). The returned buffer is owned by the caller and must be released after the write completes.
-