Allow monitoring of stdout
parent
9e5e2d41db
commit
434775623f
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
<Xterm @ref="Terminal" Options="TerminalOptions" AddonIds="TerminalAddons" />
|
<Xterm @ref="Terminal" Options="TerminalOptions" AddonIds="TerminalAddons" />
|
||||||
|
|
||||||
@if (ServerConsole.Type == ServerConsoleType.RCON)
|
@if (ServerConsole != null && ServerConsole.Type == ServerConsoleType.RCON)
|
||||||
{
|
{
|
||||||
<Input @ref="CommandInput" @bind-Value="Command" BindOnInput OnPressEnter="OnPressEnter" @onkeyup="OnCommandKeyDown" />
|
<Input @ref="CommandInput" @bind-Value="Command" BindOnInput OnPressEnter="OnPressEnter" @onkeyup="OnCommandKeyDown" />
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,56 @@
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
ServerConsole = await ServerConsoleService.Get(ServerConsoleId);
|
if (ServerConsoleId != Guid.Empty)
|
||||||
|
{
|
||||||
|
ServerConsole = await ServerConsoleService.Get(ServerConsoleId);
|
||||||
|
|
||||||
|
await Connect(ServerConsole);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await Connect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
|
{
|
||||||
|
if (firstRender)
|
||||||
|
{
|
||||||
|
await Task.Delay(100);
|
||||||
|
|
||||||
|
if (Terminal != null)
|
||||||
|
await Terminal.InvokeAddonFunctionVoidAsync("xterm-addon-fit", "fit");
|
||||||
|
|
||||||
|
if (ServerConsoleId != Guid.Empty)
|
||||||
|
{
|
||||||
|
var log = await ServerConsoleService.ReadLog(ServerConsoleId);
|
||||||
|
|
||||||
|
foreach (var line in log)
|
||||||
|
{
|
||||||
|
await Terminal.WriteLine(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async Task Connect()
|
||||||
|
{
|
||||||
|
HubConnection = new HubConnectionBuilder()
|
||||||
|
.WithUrl(NavigationManager.ToAbsoluteUri("/hubs/gameserver"))
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
HubConnection.On<Guid, string>("Log", (serverId, message) =>
|
||||||
|
{
|
||||||
|
if (serverId == ServerId)
|
||||||
|
Terminal.WriteLine(message);
|
||||||
|
});
|
||||||
|
|
||||||
|
await HubConnection.StartAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
async Task Connect(ServerConsole serverConsole)
|
||||||
|
{
|
||||||
History = new string[50];
|
History = new string[50];
|
||||||
HistoryPosition = 0;
|
HistoryPosition = 0;
|
||||||
|
|
||||||
|
@ -63,7 +111,8 @@
|
||||||
}
|
}
|
||||||
else if (ServerConsole.Type == ServerConsoleType.RCON)
|
else if (ServerConsole.Type == ServerConsoleType.RCON)
|
||||||
{
|
{
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
ServerProcessService.RconConnect(ServerConsole);
|
ServerProcessService.RconConnect(ServerConsole);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -73,24 +122,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
|
||||||
{
|
|
||||||
if (firstRender)
|
|
||||||
{
|
|
||||||
await Task.Delay(100);
|
|
||||||
|
|
||||||
if (Terminal != null)
|
|
||||||
await Terminal.InvokeAddonFunctionVoidAsync("xterm-addon-fit", "fit");
|
|
||||||
|
|
||||||
var log = await ServerConsoleService.ReadLog(ServerConsoleId);
|
|
||||||
|
|
||||||
foreach (var line in log)
|
|
||||||
{
|
|
||||||
await Terminal.WriteLine(line);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task OnPressEnter() {
|
public async Task OnPressEnter() {
|
||||||
await ServerProcessService.RconSendCommandAsync(Command, ServerConsole);
|
await ServerProcessService.RconSendCommandAsync(Command, ServerConsole);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
@page "/Servers/{id:guid}"
|
@page "/Servers/{id:guid}"
|
||||||
@page "/Servers/{id:guid}/{panel}"
|
@page "/Servers/{id:guid}/{panel}"
|
||||||
@page "/Servers/{id:guid}/{panel}/{logId:guid}"
|
@page "/Servers/{id:guid}/{panel}/{logId}"
|
||||||
@page "/Servers/Add"
|
@page "/Servers/Add"
|
||||||
@using LANCommander.Pages.Servers.Components
|
@using LANCommander.Pages.Servers.Components
|
||||||
@inject GameService GameService
|
@inject GameService GameService
|
||||||
|
@ -18,9 +18,14 @@
|
||||||
{
|
{
|
||||||
<MenuItem RouterLink="@($"/Servers/{Server.Id}/Consoles")">Consoles</MenuItem>
|
<MenuItem RouterLink="@($"/Servers/{Server.Id}/Consoles")">Consoles</MenuItem>
|
||||||
<SubMenu Key="Monitor" Title="Monitor" Disabled="@(Server.ServerConsoles == null || Server.ServerConsoles.Count == 0)">
|
<SubMenu Key="Monitor" Title="Monitor" Disabled="@(Server.ServerConsoles == null || Server.ServerConsoles.Count == 0)">
|
||||||
|
@if (!Server.UseShellExecute)
|
||||||
|
{
|
||||||
|
<MenuItem Key="Console" RouterLink="@($"/Servers/{Server.Id}/Monitor/Console")">Console</MenuItem>
|
||||||
|
}
|
||||||
|
|
||||||
@foreach (var log in Server.ServerConsoles)
|
@foreach (var log in Server.ServerConsoles)
|
||||||
{
|
{
|
||||||
<MenuItem Key="@log.Id.ToString()" RouterLink="@($"/Servers/{Server.Id}/Consoles/{log.Id}")">@log.Name</MenuItem>
|
<MenuItem Key="@log.Id.ToString()" RouterLink="@($"/Servers/{Server.Id}/Monitor/{log.Id}")">@log.Name</MenuItem>
|
||||||
}
|
}
|
||||||
</SubMenu>
|
</SubMenu>
|
||||||
<MenuItem RouterLink="@($"/Servers/{Server.Id}/Files")">Files</MenuItem>
|
<MenuItem RouterLink="@($"/Servers/{Server.Id}/Files")">Files</MenuItem>
|
||||||
|
@ -107,11 +112,14 @@
|
||||||
</Form>
|
</Form>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (Panel == "Consoles")
|
@if (Panel == "Monitor")
|
||||||
{
|
{
|
||||||
@if (LogId != null && LogId != Guid.Empty)
|
@if (LogId == "Console") {
|
||||||
|
<Console ServerId="@Server.Id" />
|
||||||
|
}
|
||||||
|
else if (LogId != null && LogId != Guid.Empty.ToString())
|
||||||
{
|
{
|
||||||
<Console ServerId="@Server.Id" ServerConsoleId="@LogId" />
|
<Console ServerId="@Server.Id" ServerConsoleId="@Guid.Parse(LogId)" />
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -146,7 +154,7 @@
|
||||||
@code {
|
@code {
|
||||||
[Parameter] public Guid Id { get; set; }
|
[Parameter] public Guid Id { get; set; }
|
||||||
[Parameter] public string Panel { get; set; }
|
[Parameter] public string Panel { get; set; }
|
||||||
[Parameter] public Guid LogId { get; set; }
|
[Parameter] public string LogId { get; set; }
|
||||||
|
|
||||||
IEnumerable<Game> Games = new List<Game>();
|
IEnumerable<Game> Games = new List<Game>();
|
||||||
|
|
||||||
|
|
|
@ -146,11 +146,13 @@ namespace LANCommander.Services
|
||||||
|
|
||||||
process.OutputDataReceived += new DataReceivedEventHandler((sender, e) =>
|
process.OutputDataReceived += new DataReceivedEventHandler((sender, e) =>
|
||||||
{
|
{
|
||||||
|
HubContext.Clients.All.SendAsync("Log", e.Data);
|
||||||
Logger.Info("Game Server {ServerName} ({ServerId}) Info: {Message}", server.Name, server.Id, e.Data);
|
Logger.Info("Game Server {ServerName} ({ServerId}) Info: {Message}", server.Name, server.Id, e.Data);
|
||||||
});
|
});
|
||||||
|
|
||||||
process.ErrorDataReceived += new DataReceivedEventHandler((sender, e) =>
|
process.ErrorDataReceived += new DataReceivedEventHandler((sender, e) =>
|
||||||
{
|
{
|
||||||
|
HubContext.Clients.All.SendAsync("Log", e.Data);
|
||||||
Logger.Error("Game Server {ServerName} ({ServerId}) Error: {Message}", server.Name, server.Id, e.Data);
|
Logger.Error("Game Server {ServerName} ({ServerId}) Error: {Message}", server.Name, server.Id, e.Data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue