Chio (Bancho I/O) is a Kotlin library for serializing and deserializing osu! Bancho packets. It targets osu! versions released between 2008 and 2026. Not all of them are implemented yet. It's a port of chio.py and chio-sharp. The API is designed for Kotlin and can also be used from Java.
Here is an example of how to use chio as a library:
// Use the client streams, or buffers for this example.
val sink: Sink = Buffer()
val source: Source = Buffer()
// Pick the protocol for the client version.
val protocol = Protocols.select(340)
// Build the user that will log in.
val info =
UserInfo(
id = 2,
name = "peppy",
presence = UserPresence(),
stats = UserStats(),
status = UserStatus(),
)
// Send the login reply, presence and stats.
val outgoing = sink.buffered()
outgoing.writeBanchoPacket(protocol, LoginReplyPacket(info.id))
outgoing.writeBanchoPacket(protocol, UserPresencePacket(info))
outgoing.writeBanchoPacket(protocol, UserStatsPacket(info))
// Join #osu and greet the player.
outgoing.writeBanchoPacket(protocol, IrcJoinPacket("#osu"))
outgoing.writeBanchoPacket(protocol, MessagePacket(Message("BanchoBot", "Hello!", "#osu")))
outgoing.flush()
// Read the next packet from the client.
val incoming = source.buffered()
val packet = incoming.readBanchoPacket(protocol)// Use the client streams, or buffers for this example.
Sink sink = new Buffer();
Source source = new Buffer();
// Pick the protocol for the client version.
Protocol protocol = Protocols.select(340);
// Build the user that will log in.
UserInfo info =
new UserInfo(2, "peppy", new UserPresence(), new UserStatus(), new UserStats());
// Send the login reply, presence and stats.
ProtocolIO.writeBanchoPacket(sink, protocol, new LoginReplyPacket(info.getId()));
ProtocolIO.writeBanchoPacket(sink, protocol, new UserPresencePacket(info));
ProtocolIO.writeBanchoPacket(sink, protocol, new UserStatsPacket(info));
// Join #osu and greet the player.
ProtocolIO.writeBanchoPacket(sink, protocol, new IrcJoinPacket("#osu"));
ProtocolIO.writeBanchoPacket(
sink, protocol, new MessagePacket(new Message("BanchoBot", "Hello!", "#osu")));
sink.flush();
// Read the next packet from the client.
InboundPacket packet = ProtocolIO.readBanchoPacket(source, protocol);Custom protocols use a ProtocolBuilder. Protocols.select is for the built-in versions; this
example uses 283, which is not registered in Protocols.
val custom =
protocol(283) {
decode(PacketType.OsuExit) { ExitPacket }
encode<LoginReplyPacket>(PacketType.BanchoLoginReply) { writeInt(it.reply) }
encodeEmpty<PingPacket>(PacketType.BanchoPing)
}ProtocolBuilder builder = new ProtocolBuilder(283);
builder.decode(PacketType.OsuExit, (protocol1, reader) -> ExitPacket.INSTANCE);
builder.encode(
LoginReplyPacket.class,
PacketType.BanchoLoginReply,
(writer, reply) -> writer.writeInt(reply.getReply()));
builder.encodeEmpty(PingPacket.class, PacketType.BanchoPing);
Protocol custom = builder.build();just --list
just build
just check
just test
just format
just lint
just cleannix develop
nix buildnix build writes the JAR to result/share/java/. The dev shell has JDK 25 and
just. Run direnv allow to load it from .envrc.
Update nix/packages/chio/deps.json with
nix build .#chio.mitmCache.updateScript && ./result.
- Levi for creating and maintaining chio.py, chio-sharp and bancho-documentation.