using MessagePack;
using SHH.CameraDashboard;
using SHH.CameraDashboard.Services;
using SHH.Contracts;

public class RegisterProcessor : IProtocolProcessor
{
    public string ProtocolType => ProtocolHeaders.ServerRegister;

    private readonly CommandBusClient _bus;

    public RegisterProcessor(CommandBusClient bus) => _bus = bus;

    public void Process(byte[] identity, byte[] payloadBytes)
    {
        var p = MessagePackSerializer.Deserialize<RegisterPayload>(payloadBytes);
        _bus.UpdateSession(p.InstanceId, identity);
        _bus.RaiseServerRegistered(p);
    }
}