//..............................................................................
//
// UDP log representer
//

import "UdpLogRecordCode.jnc"
import "log_Representer.jnc"
import "io_base.jncx"
import "io_SocketAddress.jnc"

//..............................................................................

bool representUdpLog(
	log.RepresenterTarget* target,
	uint64_t recordCode,
	void const* p,
	size_t size,
	uint_t foldFlags
	)
{
	switch (recordCode)
	{
	case UdpLogRecordCode.TxPacket:
		char const* remoteAddress = ((io.SocketAddress const*) p).getString();
		target.m_lineAttr.m_iconIdx = log.StdLogIcon.TxPacket;
		target.m_lineAttr.m_backColor = gui.StdColor.PastelGray;
		target.addHyperText($"To \e[34m$remoteAddress");
		break;

	case UdpLogRecordCode.RxPacket:
		char const* remoteAddress = ((io.SocketAddress const*) p).getString();
		target.m_lineAttr.m_iconIdx = log.StdLogIcon.RxPacket;
		target.m_lineAttr.m_backColor = gui.StdColor.PastelGray;
		target.addHyperText($"From \e[34m$remoteAddress");
		break;

	default:
		return false;
	}

	return true;
}

//..............................................................................
