use of io.gomint.proxprox.network.tcp.protocol.UpdatePingPacket 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);
}
}
use of io.gomint.proxprox.network.tcp.protocol.UpdatePingPacket in project ProxProx by GoMint.
the class Decoder method decode.
@Override
protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf buf, List<Object> objects) throws Exception {
if (buf instanceof EmptyByteBuf) {
// The Channel has disconnected and this is the last message we got. R.I.P. connection
return;
}
byte packetId = buf.readByte();
switch(packetId) {
case 1:
WrappedMCPEPacket wrappedMCPEPacket = new WrappedMCPEPacket();
wrappedMCPEPacket.read(buf);
objects.add(wrappedMCPEPacket);
break;
case 2:
UpdatePingPacket updatePingPacket = new UpdatePingPacket();
updatePingPacket.read(buf);
objects.add(updatePingPacket);
break;
case 3:
SendPlayerToServerPacket sendPlayerToServerPacket = new SendPlayerToServerPacket();
sendPlayerToServerPacket.read(buf);
objects.add(sendPlayerToServerPacket);
break;
default:
break;
}
}
Aggregations