using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.SignalR;
using RobotNet.Script.Shares;
using RobotNet.ScriptManager.Services;
using RobotNet.Shares;

namespace RobotNet.ScriptManager.Hubs;

[Authorize]
public class ProcessorHub(ScriptStateManager scriptBuilder) : Hub
{
    public ProcessorState GetState() => scriptBuilder.State;

    public ProcessorRequest GetRequest() => scriptBuilder.Request;

    public MessageResult Build()
    {
        var message = "";
        var result = scriptBuilder.Build(ref message);

        return new(result, message);
    }

    public MessageResult Run()
    {
        var message = "";
        var result = scriptBuilder.Run(ref message);

        return new(result, message);
    }

    public MessageResult Stop()
    {
        var message = "";
        var result = scriptBuilder.Stop(ref message);

        return new(result, message);
    }

    public MessageResult Reset()
    {
        var message = "";
        var result = scriptBuilder.Reset(ref message);

        return new(result, message);
    }
}
