Skip to content

[Networking] Improve handling of legacy channel format - #90

Open
SpaceWalkerRS wants to merge 1 commit into
gen2from
improve-legacy-packet-channel-support
Open

[Networking] Improve handling of legacy channel format#90
SpaceWalkerRS wants to merge 1 commit into
gen2from
improve-legacy-packet-channel-support

Conversation

@SpaceWalkerRS

Copy link
Copy Markdown
Member

resolves #89

Channel Identifiers

Currently, the way channels identifiers are converted to and from Strings is different in 1.13-pre2 and below vs 1.13-pre4 and above.

In 1.13-pre4 and above, Vanilla uses Identifiers for custom payload channels, and OSL does as well. As such, there is no special handling for String conversions, and the standard colon-separated format is used: <namespace>:<identifier>.

ChannelIdentifiers.from("example", "cookie"); // String representation -> "example:cookie"

In 1.13-pre2 and below, Vanilla uses Strings for custom payload channels, with no validation exception for limiting the length to 20 (or 16 in older versions). However, by convention, a sort of namespaced identifier is used with a vertical bar separator (|). All channel identifiers made through OSL are serialized to this legacy format.

ChannelIdentifiers.from("EXAMPLE", "Cookie"); // String representation -> "EXAMPLE|Cookie"

Changes

  • Channel identifiers created through ChannelIdentifiers.from() now ALWAYS serialize to the standard colon-separated format.
  • New factory ChannelIdentifiers.fromLegacy() methods are added that create channel identifiers that ALWAYS serialize to the legacy vertical-bar-separated format.
ChannelIdentifiers.from("example", "cookie"); // String representation -> "example:cookie"
ChannelIdentifiers.fromLegacy("example", "cookie"); // String representation -> "example|cookie"

Note on breaking changes and compatibility

This is a breaking change, and any mod for 1.13-pre2 and below that uses OSL for networking will behave differently with OSL 0.21 vs. this update. If keeping compatibility is important, use the new fromLegacy factory methods to keep compatibility for communication with OSL 0.21.

@SpaceWalkerRS SpaceWalkerRS added the enhancement New feature or request label Sep 12, 2026

@Yedelo Yedelo left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allows colons to be parsed in StringChannelIdentifierParser#fromString with the proper namespace and identifer, looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add support for colon separated identifiers for networking

2 participants