Skip to content
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.
/ Packet-Channels Public archive

A simple client/server library utilizing packet structures over NIO channels

License

Notifications You must be signed in to change notification settings

Col-E/Packet-Channels

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Packet Channels

A simple client/server library utilizing packet structures over java.nio.channels.

Usage

Create an extension of the Client and Server classes. Call start() on the server then on a client.

By default, the only supported packets are a simple alive check (AlivePacket), and a connection close notification (ClosePacket).

To register more packet types:

PacketFactory.register(PACKET_ID, CustomPacket::new);

And to add custom behavior in response to a packet, both the client and server follow the same semantics:

// In the client or server implementations
@Override
protected void setup(PacketHandlerDelegator delegator) {
    delegator.register(PACKET_ID, this::handleCustom);
}

private boolean handleCustom(ByteChannel channel, CustomPacket packet) {
    // ... do something with 'packet'
    return true;
}

To send a Packet from the Client to the Server a Client can call write(packet).

To send a Packet from the Server back to a Client the Server must specify the target channel via PacketIO.write(channel, packet).

About

A simple client/server library utilizing packet structures over NIO channels

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages