Search in sources :

Example 1 with SyncScheduledTask

use of io.gomint.proxprox.scheduler.SyncScheduledTask in project ProxProx by GoMint.

the class UpstreamConnection method update.

public void update() {
    if (this.disconnect != null && !this.disconnectNotified) {
        // Delay closing connection so the client has enough time to react
        ProxProx.instance.getSyncTaskManager().addTask(new SyncScheduledTask(() -> {
            UpstreamConnection.this.connection.disconnect(UpstreamConnection.this.disconnect);
        }, 5, -1, TimeUnit.SECONDS));
        this.disconnectNotified = true;
        if (this.pendingDownStream != null) {
            this.pendingDownStream.disconnect(this.disconnect);
            this.pendingDownStream = null;
        }
        if (this.currentDownStream != null) {
            this.currentDownStream.disconnect(this.disconnect);
            this.currentDownStream = null;
        }
    }
    // Update downstream ping
    if (this.proxProx.getConfig().isUseTCP() && this.currentDownStream != null) {
        UpdatePingPacket pingPacket = new UpdatePingPacket();
        pingPacket.setPing((int) this.connection.getPing());
        this.currentDownStream.getTcpConnection().send(pingPacket);
    }
}
Also used : UpdatePingPacket(io.gomint.proxprox.network.tcp.protocol.UpdatePingPacket) SyncScheduledTask(io.gomint.proxprox.scheduler.SyncScheduledTask)

Aggregations

UpdatePingPacket (io.gomint.proxprox.network.tcp.protocol.UpdatePingPacket)1 SyncScheduledTask (io.gomint.proxprox.scheduler.SyncScheduledTask)1