package ru.dbotthepony.kstarbound.network.packets

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

object PongPacket : IClientPacket {
	override fun write(stream: DataOutputStream, isLegacy: Boolean) {
		if (isLegacy) stream.write(0)
	}

	override fun play(connection: ClientConnection) {
		TODO("Not yet implemented")
	}

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

object PingPacket : IServerPacket {
	override fun write(stream: DataOutputStream, isLegacy: Boolean) {
		if (isLegacy) stream.write(0)
	}

	override fun play(connection: ServerConnection) {
		connection.send(PongPacket)
	}

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