package org.pixelndice.table.pixelclient.connection.main.state06joingamebyuuid

import org.apache.logging.log4j.LogManager
import org.pixelndice.table.pixelclient.connection.main.Context
import org.pixelndice.table.pixelclient.connection.main.State
import org.pixelndice.table.pixelclient.gameTag
import org.pixelndice.table.pixelprotocol.Protobuf

private val logger = LogManager.getLogger(State07SendingQueryGameByUUID::class.java)

class State07SendingQueryGameByUUID: State {

    override fun process(ctx: Context): Unit {

        val queryGame = Protobuf.QueryGame.newBuilder()
        val resp = Protobuf.Packet.newBuilder()

        queryGame.setUuid(gameTag)

        resp.setQueryGame(queryGame.build())

        ctx.packet = resp.build()

        ctx.state = State08WaitingQueryGameByUUID()

        logger.debug("Sending query game $gameTag")
    }
}