package ru.dbotthepony.kstarbound.network.packets.clientbound

import ru.dbotthepony.kommons.io.readBinaryString
import ru.dbotthepony.kommons.io.writeBinaryString
import ru.dbotthepony.kstarbound.client.ClientConnection
import ru.dbotthepony.kstarbound.network.IClientPacket
import java.io.DataInputStream
import java.io.DataOutputStream

class ServerDisconnectPacket(val reason: String = "") : IClientPacket {
	constructor(stream: DataInputStream, isLegacy: Boolean) : this(stream.readBinaryString())

	override fun write(stream: DataOutputStream, isLegacy: Boolean) {
		stream.writeBinaryString(reason)
	}

	override fun play(connection: ClientConnection) {
		connection.disconnectNow()
	}
}
