Subs
News
Meowlib
1.8.10
Complexer
pisiEventApi
Sh4ll

meowlib

Networking

Creating a TCP Server

WTcpServer server = new WTCPServer(IPAddress.ANY, 2173);
server.listen();

Connection Event

When a client gets connected the 'connectionRequestEvent' event gets called
server.connectionRequestEvent.bind(new DSConnectionRequest() {
    @Override
    public void onClientConnecting(SocketClient client) {
        System.out.println("Client Connected");
    }
});

Data Received Event

server.dataReceivedEvent.bind(new DSDataReceived() {
    @Override
    public void onDataReceived(SocketClient client, byte[] data) {

    }
});

Interacting with client

You can kick the client using
client.kick();
// or
server.kick(client);
You can send data to client using
client.send(data); // data is byte[]

SocketClient fields/methods

Method/Field Description
connectedServer() returns the server client connected to
socketChannel() returns the raw nio SocketChannel
getWriteQueue() returns bytes in queue
kick() kicks client from the server
close() closes the connection (use kick() instead)

WTcpServer fields/methods

Method/Field Description
listen() starts listening the socket
stop() stops listening the socket
connectionRequestEvent connection listener event
dataReceivedEvent data received listener event
setKeepAlive(boolean) built in keepalive system
bindAddress() returns the listening socket address