Location Sharing

This commit is contained in:
Tsubasahane
2025-12-27 19:57:21 +08:00
parent 5c8e239a7b
commit 70745613e1
12 changed files with 224 additions and 6 deletions

View File

@@ -200,5 +200,17 @@ public partial class ApiController
await UserPushData(new(visibleCharacters, character, censusDto)).ConfigureAwait(false);
}
public async Task UpdateLocation(LocationDto locationDto, bool offline = false)
{
if (!IsConnected) return;
await _lightlessHub!.SendAsync(nameof(UpdateLocation), locationDto, offline).ConfigureAwait(false);
}
public async Task<List<LocationDto>> RequestAllLocationInfo()
{
if (!IsConnected) return [];
return await _lightlessHub!.InvokeAsync<List<LocationDto>>(nameof(RequestAllLocationInfo)).ConfigureAwait(false);
}
}
#pragma warning restore MA0040

View File

@@ -259,6 +259,13 @@ public partial class ApiController
ExecuteSafely(() => Mediator.Publish(new GPoseLobbyReceiveWorldData(userData, worldData)));
return Task.CompletedTask;
}
public Task Client_SendLocationToClient(LocationDto locationDto)
{
Logger.LogDebug($"{nameof(Client_SendLocationToClient)}: {locationDto.user}");
ExecuteSafely(() => Mediator.Publish(new LocationMessage(locationDto.user.UID, locationDto.location)));
return Task.CompletedTask;
}
public void OnDownloadReady(Action<Guid> act)
{
@@ -440,6 +447,12 @@ public partial class ApiController
if (_initialized) return;
_lightlessHub!.On(nameof(Client_GposeLobbyPushWorldData), act);
}
public void OnReciveLocation(Action<LocationDto> act)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_SendLocationToClient), act);
}
private void ExecuteSafely(Action act)
{

View File

@@ -606,6 +606,8 @@ public sealed partial class ApiController : DisposableMediatorSubscriberBase, IL
OnGposeLobbyPushCharacterData((dto) => _ = Client_GposeLobbyPushCharacterData(dto));
OnGposeLobbyPushPoseData((dto, data) => _ = Client_GposeLobbyPushPoseData(dto, data));
OnGposeLobbyPushWorldData((dto, data) => _ = Client_GposeLobbyPushWorldData(dto, data));
OnReciveLocation(dto => _ = Client_SendLocationToClient(dto));
_healthCheckTokenSource?.Cancel();
_healthCheckTokenSource?.Dispose();