mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Add detection for reserved/private server types
This commit is contained in:
parent
5205287f36
commit
890f7a14df
9
Bloxstrap/Enums/ServerType.cs
Normal file
9
Bloxstrap/Enums/ServerType.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
namespace Bloxstrap.Enums
|
||||||
|
{
|
||||||
|
public enum ServerType
|
||||||
|
{
|
||||||
|
Public,
|
||||||
|
Private,
|
||||||
|
Reserved
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,8 @@
|
|||||||
// i'm thinking the functionality for parsing roblox logs could be broadened for more features than just rich presence,
|
// i'm thinking the functionality for parsing roblox logs could be broadened for more features than just rich presence,
|
||||||
// like checking the ping and region of the current connected server. maybe that's something to add?
|
// like checking the ping and region of the current connected server. maybe that's something to add?
|
||||||
private const string GameJoiningEntry = "[FLog::Output] ! Joining game";
|
private const string GameJoiningEntry = "[FLog::Output] ! Joining game";
|
||||||
|
private const string GameJoiningPrivateServerEntry = "[FLog::GameJoinUtil] GameJoinUtil::joinGamePostPrivateServer";
|
||||||
|
private const string GameJoiningReservedServerEntry = "[FLog::GameJoinUtil] GameJoinUtil::initiateTeleportToReservedServer";
|
||||||
private const string GameJoiningUDMUXEntry = "[FLog::Network] UDMUX Address = ";
|
private const string GameJoiningUDMUXEntry = "[FLog::Network] UDMUX Address = ";
|
||||||
private const string GameJoinedEntry = "[FLog::Network] serverId:";
|
private const string GameJoinedEntry = "[FLog::Network] serverId:";
|
||||||
private const string GameDisconnectedEntry = "[FLog::Network] Time to disconnect replication data:";
|
private const string GameDisconnectedEntry = "[FLog::Network] Time to disconnect replication data:";
|
||||||
@ -17,6 +19,7 @@
|
|||||||
|
|
||||||
private int _logEntriesRead = 0;
|
private int _logEntriesRead = 0;
|
||||||
private bool _teleportMarker = false;
|
private bool _teleportMarker = false;
|
||||||
|
private bool _reservedTeleportMarker = false;
|
||||||
|
|
||||||
public event EventHandler<string>? OnLogEntry;
|
public event EventHandler<string>? OnLogEntry;
|
||||||
public event EventHandler? OnGameJoin;
|
public event EventHandler? OnGameJoin;
|
||||||
@ -28,12 +31,14 @@
|
|||||||
public string LogFilename = null!;
|
public string LogFilename = null!;
|
||||||
|
|
||||||
// these are values to use assuming the player isn't currently in a game
|
// these are values to use assuming the player isn't currently in a game
|
||||||
|
// hmm... do i move this to a model?
|
||||||
public bool ActivityInGame = false;
|
public bool ActivityInGame = false;
|
||||||
public long ActivityPlaceId = 0;
|
public long ActivityPlaceId = 0;
|
||||||
public string ActivityJobId = "";
|
public string ActivityJobId = "";
|
||||||
public string ActivityMachineAddress = "";
|
public string ActivityMachineAddress = "";
|
||||||
public bool ActivityMachineUDMUX = false;
|
public bool ActivityMachineUDMUX = false;
|
||||||
public bool ActivityIsTeleport = false;
|
public bool ActivityIsTeleport = false;
|
||||||
|
public ServerType ActivityServerType = ServerType.Public;
|
||||||
|
|
||||||
public bool IsDisposed = false;
|
public bool IsDisposed = false;
|
||||||
|
|
||||||
@ -113,7 +118,14 @@
|
|||||||
else if (_logEntriesRead % 100 == 0)
|
else if (_logEntriesRead % 100 == 0)
|
||||||
App.Logger.WriteLine($"[RobloxActivity::ExamineLogEntry] Read {_logEntriesRead} log entries");
|
App.Logger.WriteLine($"[RobloxActivity::ExamineLogEntry] Read {_logEntriesRead} log entries");
|
||||||
|
|
||||||
if (!ActivityInGame && ActivityPlaceId == 0 && entry.Contains(GameJoiningEntry))
|
if (!ActivityInGame && ActivityPlaceId == 0)
|
||||||
|
{
|
||||||
|
if (entry.Contains(GameJoiningPrivateServerEntry))
|
||||||
|
{
|
||||||
|
// we only expect to be joining a private server if we're not already in a game
|
||||||
|
ActivityServerType = ServerType.Private;
|
||||||
|
}
|
||||||
|
else if (entry.Contains(GameJoiningEntry))
|
||||||
{
|
{
|
||||||
Match match = Regex.Match(entry, GameJoiningEntryPattern);
|
Match match = Regex.Match(entry, GameJoiningEntryPattern);
|
||||||
|
|
||||||
@ -134,13 +146,16 @@
|
|||||||
ActivityIsTeleport = true;
|
ActivityIsTeleport = true;
|
||||||
_teleportMarker = false;
|
_teleportMarker = false;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (_reservedTeleportMarker)
|
||||||
{
|
{
|
||||||
ActivityIsTeleport = false;
|
ActivityServerType = ServerType.Reserved;
|
||||||
|
_reservedTeleportMarker = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
App.Logger.WriteLine($"[RobloxActivity::ExamineLogEntry] Joining Game ({ActivityPlaceId}/{ActivityJobId}/{ActivityMachineAddress})");
|
App.Logger.WriteLine($"[RobloxActivity::ExamineLogEntry] Joining Game ({ActivityPlaceId}/{ActivityJobId}/{ActivityMachineAddress})");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (!ActivityInGame && ActivityPlaceId != 0)
|
else if (!ActivityInGame && ActivityPlaceId != 0)
|
||||||
{
|
{
|
||||||
if (entry.Contains(GameJoiningUDMUXEntry))
|
if (entry.Contains(GameJoiningUDMUXEntry))
|
||||||
@ -187,6 +202,8 @@
|
|||||||
ActivityJobId = "";
|
ActivityJobId = "";
|
||||||
ActivityMachineAddress = "";
|
ActivityMachineAddress = "";
|
||||||
ActivityMachineUDMUX = false;
|
ActivityMachineUDMUX = false;
|
||||||
|
ActivityIsTeleport = false;
|
||||||
|
ActivityServerType = ServerType.Public;
|
||||||
|
|
||||||
OnGameLeave?.Invoke(this, new EventArgs());
|
OnGameLeave?.Invoke(this, new EventArgs());
|
||||||
}
|
}
|
||||||
@ -195,6 +212,11 @@
|
|||||||
App.Logger.WriteLine($"[RobloxActivity::ExamineLogEntry] Initiating teleport to server ({ActivityPlaceId}/{ActivityJobId}/{ActivityMachineAddress})");
|
App.Logger.WriteLine($"[RobloxActivity::ExamineLogEntry] Initiating teleport to server ({ActivityPlaceId}/{ActivityJobId}/{ActivityMachineAddress})");
|
||||||
_teleportMarker = true;
|
_teleportMarker = true;
|
||||||
}
|
}
|
||||||
|
else if (_teleportMarker && entry.Contains(GameJoiningReservedServerEntry))
|
||||||
|
{
|
||||||
|
// we only expect to be joining a reserved server if we're teleporting to one from a game
|
||||||
|
_reservedTeleportMarker = true;
|
||||||
|
}
|
||||||
else if (entry.Contains(GameMessageEntry))
|
else if (entry.Contains(GameMessageEntry))
|
||||||
{
|
{
|
||||||
string messagePlain = entry.Substring(entry.IndexOf(GameMessageEntry) + GameMessageEntry.Length + 1);
|
string messagePlain = entry.Substring(entry.IndexOf(GameMessageEntry) + GameMessageEntry.Length + 1);
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
MinWidth="0"
|
MinWidth="0"
|
||||||
MinHeight="0"
|
MinHeight="0"
|
||||||
Width="400"
|
Width="400"
|
||||||
Height="230"
|
SizeToContent="Height"
|
||||||
ResizeMode="NoResize"
|
ResizeMode="NoResize"
|
||||||
Background="{ui:ThemeResource ApplicationBackgroundBrush}"
|
Background="{ui:ThemeResource ApplicationBackgroundBrush}"
|
||||||
ExtendsContentIntoTitleBar="True"
|
ExtendsContentIntoTitleBar="True"
|
||||||
@ -26,17 +26,30 @@
|
|||||||
|
|
||||||
<ui:TitleBar Grid.Row="0" Grid.ColumnSpan="2" Padding="8" x:Name="RootTitleBar" Title="Server information" ShowMinimize="False" ShowMaximize="False" CanMaximize="False" KeyboardNavigation.TabNavigation="None" Icon="pack://application:,,,/Bloxstrap.ico" />
|
<ui:TitleBar Grid.Row="0" Grid.ColumnSpan="2" Padding="8" x:Name="RootTitleBar" Title="Server information" ShowMinimize="False" ShowMaximize="False" CanMaximize="False" KeyboardNavigation.TabNavigation="None" Icon="pack://application:,,,/Bloxstrap.ico" />
|
||||||
|
|
||||||
<StackPanel Grid.Row="1" Margin="12">
|
<Grid Grid.Row="1" Margin="16,8,16,16">
|
||||||
<TextBlock Text="Instance ID" FontSize="16" FontWeight="Medium" />
|
<Grid.RowDefinitions>
|
||||||
<TextBlock Text="{Binding InstanceId, Mode=OneWay}" />
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<TextBlock Margin="0,16,0,0" Text="Server location" FontSize="16" FontWeight="Medium" />
|
<TextBlock Grid.Row="0" Grid.Column="0" Margin="0,0,16,8" VerticalAlignment="Center" Text="Type" />
|
||||||
<TextBlock Text="{Binding ServerLocation, Mode=OneWay}" />
|
<TextBlock Grid.Row="0" Grid.Column="1" Foreground="{DynamicResource TextFillColorTertiaryBrush}" Text="{Binding ServerType, Mode=OneWay}" />
|
||||||
</StackPanel>
|
|
||||||
|
|
||||||
<Border Grid.Row="2" Margin="0,10,0,0" Padding="15" Background="{ui:ThemeResource SolidBackgroundFillColorSecondaryBrush}">
|
<TextBlock Grid.Row="1" Grid.Column="0" Margin="0,0,16,8" VerticalAlignment="Center" Text="Instance ID" />
|
||||||
|
<TextBlock Grid.Row="1" Grid.Column="1" Foreground="{DynamicResource TextFillColorTertiaryBrush}" Text="{Binding InstanceId, Mode=OneWay}" />
|
||||||
|
|
||||||
|
<TextBlock Grid.Row="2" Grid.Column="0" Margin="0,0,16,0" VerticalAlignment="Center" Text="Location" />
|
||||||
|
<TextBlock Grid.Row="2" Grid.Column="1" Foreground="{DynamicResource TextFillColorTertiaryBrush}" Text="{Binding ServerLocation, Mode=OneWay}" />
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<Border Grid.Row="2" Padding="15" Background="{ui:ThemeResource SolidBackgroundFillColorSecondaryBrush}">
|
||||||
<StackPanel Orientation="Horizontal" FlowDirection="LeftToRight" HorizontalAlignment="Right">
|
<StackPanel Orientation="Horizontal" FlowDirection="LeftToRight" HorizontalAlignment="Right">
|
||||||
<Button MinWidth="100" Content="Copy instance ID" Command="{Binding CopyInstanceIdCommand, Mode=OneTime}" />
|
<Button MinWidth="100" Content="Copy Instance ID" Command="{Binding CopyInstanceIdCommand, Mode=OneTime}" />
|
||||||
<Button Margin="12,0,0,0" MinWidth="100" Content="Close" Command="{Binding CloseWindowCommand, Mode=OneTime}" />
|
<Button Margin="12,0,0,0" MinWidth="100" Content="Close" Command="{Binding CloseWindowCommand, Mode=OneTime}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Border>
|
</Border>
|
||||||
|
@ -78,7 +78,13 @@ namespace Bloxstrap.UI
|
|||||||
public async void OnGameJoin()
|
public async void OnGameJoin()
|
||||||
{
|
{
|
||||||
string serverLocation = await _activityWatcher!.GetServerLocation();
|
string serverLocation = await _activityWatcher!.GetServerLocation();
|
||||||
ShowAlert("Connnected to server", $"Location: {serverLocation}\nClick for more information", 10, (_, _) => _menuContainer?.ShowServerInformationWindow());
|
|
||||||
|
ShowAlert(
|
||||||
|
$"Connnected to {_activityWatcher.ActivityServerType.ToString().ToLower()} server",
|
||||||
|
$"Located at {serverLocation}\nClick for more information",
|
||||||
|
10,
|
||||||
|
(_, _) => _menuContainer?.ShowServerInformationWindow()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ namespace Bloxstrap.UI.ViewModels.ContextMenu
|
|||||||
private readonly RobloxActivity _activityWatcher;
|
private readonly RobloxActivity _activityWatcher;
|
||||||
|
|
||||||
public string InstanceId => _activityWatcher.ActivityJobId;
|
public string InstanceId => _activityWatcher.ActivityJobId;
|
||||||
|
public string ServerType => $"{_activityWatcher.ActivityServerType} server";
|
||||||
public string ServerLocation { get; private set; } = "Loading, please wait...";
|
public string ServerLocation { get; private set; } = "Loading, please wait...";
|
||||||
|
|
||||||
public ICommand CopyInstanceIdCommand => new RelayCommand(CopyInstanceId);
|
public ICommand CopyInstanceIdCommand => new RelayCommand(CopyInstanceId);
|
||||||
|
Loading…
Reference in New Issue
Block a user