40 lines
1007 B
Plaintext
40 lines
1007 B
Plaintext
@using Microsoft.AspNetCore.SignalR.Client
|
|
@using MoonlightServers.Frontend.Services
|
|
|
|
@inherits BaseServerTab
|
|
|
|
@inject ServerService ServerService
|
|
|
|
<div class="h-44">
|
|
<XtermConsole @ref="XtermConsole"
|
|
OnAfterInitialized="OnAfterConsoleInitialized"
|
|
CommandHistory="Parent.CommandHistory"
|
|
OnCommand="OnCommand"/>
|
|
</div>
|
|
|
|
@code
|
|
{
|
|
private XtermConsole? XtermConsole;
|
|
|
|
protected override Task OnInitializedAsync()
|
|
{
|
|
// We are already connected to the hub at this point
|
|
|
|
HubConnection.On<string>("ConsoleOutput", async content =>
|
|
{
|
|
if (XtermConsole != null)
|
|
await XtermConsole.Write(content);
|
|
});
|
|
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
private async Task OnAfterConsoleInitialized()
|
|
{
|
|
await XtermConsole!.Write(InitialConsoleMessage);
|
|
}
|
|
|
|
private async Task OnCommand(string command)
|
|
=> await ServerService.RunCommand(Server.Id, command + "\n");
|
|
}
|