package ru.dbotthepony.kstarbound.network.packets.serverbound

import ru.dbotthepony.kstarbound.network.IServerPacket
import ru.dbotthepony.kstarbound.server.ServerConnection
import java.io.DataInputStream
import java.io.DataOutputStream

object ClientDisconnectRequestPacket : IServerPacket {
	override fun write(stream: DataOutputStream, isLegacy: Boolean) {
		if (isLegacy) stream.writeBoolean(false)
	}

	override fun play(connection: ServerConnection) {
		connection.disconnect("Disconnect by user.")
	}

	fun read(stream: DataInputStream, isLegacy: Boolean): ClientDisconnectRequestPacket {
		if (isLegacy) stream.readBoolean()
		return ClientDisconnectRequestPacket
	}
}
