An open API service indexing awesome lists of open source software.

https://github.com/by1337/btcpapi


https://github.com/by1337/btcpapi

Last synced: 2 months ago
JSON representation

Awesome Lists containing this project

README

        

# BTCPApi

BTCPApi is a simple API for communication between a server and a client via TCP. This library was primarily created for data synchronization on Minecraft servers.

## Synchronization Architecture

All synchronization is built on the following system:

`client-plugin` -> `BTCP-plugin` -> `BTCP-server` -> `server-plugin`

## Installation

To use BTCPApi in your project, add the following dependencies to your `pom.xml`:

```xml



by1337
https://repo.by1337.space/repository/maven-releases/



org.by1337.tcpapi.api
BTCP-Api
1.0
provided



org.by1337.tcpapi.client
BTcpClient
1.0
provided



org.by1337.tcpapi.server
BTcpServer
1.0
provided

```

## Usage Examples

### Server

```java
ServerChannelStream stream = ServerManager.getChannelStreamManager().registerChannelStream(new SpacedNameKey("myPlugin:channel"), MyChannelListenerImpl);
for (Client client : stream.getAllClients()) {
stream.sendTo(client, new PacketPingRequest());
}
```

### Client

```java
ClientChannelStream stream = Manager.getChannelStreamManager().registerChannelStream(new SpacedNameKey("myPlugin:channel"), MyChannelStreamPacketReaderImpl);
stream.register().lock(10_000);
if (stream.getStatus() != ChannelStatus.OPENED){
throw new IllegalStateException("Failed to establish connection with the TCP server!");
}
stream.write(new PacketPingRequest());
```

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.