Implemented server console streaming in the frontend with xterm. Added logs endpoint for servers
This commit is contained in:
@@ -32,6 +32,20 @@ public class ServersController : Controller
|
||||
};
|
||||
}
|
||||
|
||||
[HttpGet("{serverId:int}/logs")]
|
||||
public async Task<ServerLogsResponse> GetLogs([FromRoute] int serverId)
|
||||
{
|
||||
var server = ServerService.GetServer(serverId);
|
||||
|
||||
if (server == null)
|
||||
throw new HttpApiException("No server with this id found", 404);
|
||||
|
||||
return new ServerLogsResponse()
|
||||
{
|
||||
Messages = server.Console.Messages
|
||||
};
|
||||
}
|
||||
|
||||
[HttpPost("{serverId:int}/start")]
|
||||
public async Task Start(int serverId)
|
||||
{
|
||||
|
||||
@@ -17,12 +17,24 @@ public class ServerConsoleHub : Hub
|
||||
ConsoleService = consoleService;
|
||||
}
|
||||
|
||||
#region Connection Handlers
|
||||
|
||||
public override async Task OnConnectedAsync()
|
||||
=> await ConsoleService.InitializeClient(Context);
|
||||
|
||||
public override async Task OnDisconnectedAsync(Exception? exception)
|
||||
=> await ConsoleService.DestroyClient(Context);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
[HubMethodName("Authenticate")]
|
||||
public async Task Authenticate(string accessToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
await ConsoleService.Authenticate(Context, accessToken);
|
||||
await ConsoleService.AuthenticateClient(Context, accessToken);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -30,6 +42,5 @@ public class ServerConsoleHub : Hub
|
||||
}
|
||||
}
|
||||
|
||||
public override async Task OnDisconnectedAsync(Exception? exception)
|
||||
=> await ConsoleService.OnClientDisconnected(Context);
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user