Files
LightlessClient/LightlessSync/WebAPI/SignalR/ApiController.Functions.Callbacks.cs
defnotken 72a62b7449
All checks were successful
Tag and Release Lightless / tag-and-release (push) Successful in 2m9s
2.1.0 (#123)
# Patchnotes 2.1.0
The changes in this update are more than just "patches". With a new UI, a new feature, and a bunch of bug fixes, improvements and a new member on the dev team, we thought this was more of a minor update.

We would like to introduce @tsubasahane of MareCN to the team! We’re happy to work with them to bring Lightless and its features to the CN client as well as having another talented dev bring features and ideas to us. Speaking of which:

# Location Sharing (Big shout out to @tsubasahane for bringing this feature)

- Are you TIRED of scrambling to find the address of the venue you're in to share with your friends? We are introducing Location Sharing! An optional feature where you can share your location with direct pairs temporarily [30 minutes, 1 hour, 3 hours] minutes or until you turn it off for them. That's up to you! [#125](<#125>)  [#49](<Lightless-Sync/LightlessServer#49>)
- To share your location with a pair, click the three dots beside the pair and choose a duration to share with them. [#125](<#125>)  [#49](<Lightless-Sync/LightlessServer#49>)
- To view the location of someone who's shared with you, simply hover over the globe icon! [#125](<#125>)  [#49](<Lightless-Sync/LightlessServer#49>)

[1]

# Model Optimization (Mesh Decimating)
 - This new option can automatically “simplify” incoming character meshes to help performance by reducing triangle counts. You choose how strong the reduction is (default/recommended is 80%). [#131](<#131>)
 - Decimation only kicks in when a mesh is above a certain triangle threshold, and only for the items that qualify for it and you selected for. [#131](<#131>)
 - Hair meshes is always excluded, since simplifying hair meshes is very prone to breaking.
 - You can find everything under Settings → Performance → Model Optimization. [#131](<#131>)
+ ** IF YOU HAVE USED DECIMATION IN TESTING, PLEASE CLEAR YOUR CACHE  **

[2]

# Animation (PAP) Validation (Safer animations)
 - Lightless now checks your currently animations to see if they work with your local skeleton/bone mod. If an animation matches, it’s included in what gets sent to other players. If it doesn’t, Lightless will skip it and write a warning to your log showing how many were skipped due to skeleton changes. Its defaulted to Unsafe (off). turn it on if you experience crashes from others users. [#131](<#131>)
 - Lightless also does the same kind of check for incoming animation files, to make sure they match the body/skeleton they were sent with. [#131](<#131>)
 - Because these checks can sometimes be a little picky, you can adjust how strict they are in Settings -> General -> Animation & Bones to reduce false positives. [#131](<#131>)

# UI Changes (Thanks to @kyuwu for UI Changes)
- The top part of the main screen has gotten a makeover. You can adjust the colors of the gradiant in the Color settings of Lightless. [#127](<#127>)

[3]

- Settings have gotten some changes as well to make this change more universal, and will use the same color settings. [#127](<#127>)
- The particle effects of the gradient are toggleable in 'Settings -> UI -> Behavior' [#127](<#127>)
- Instead of showing download/upload on bottom of Main UI, it will show VRAM usage and triangles with their optimization options next to it [#138](<#138>)

# LightFinder / ShellFinder
- UI Changes that follow our new design follow the color codes for the Gradient top as the main screen does.  [#127](<#127>)

[4]

Co-authored-by: defnotken <itsdefnotken@gmail.com>
Co-authored-by: azyges <aaaaaa@aaa.aaa>
Co-authored-by: cake <admin@cakeandbanana.nl>
Co-authored-by: Tsubasa <tsubasa@noreply.git.lightless-sync.org>
Co-authored-by: choco <choco@patat.nl>
Co-authored-by: celine <aaa@aaa.aaa>
Co-authored-by: celine <celine@noreply.git.lightless-sync.org>
Co-authored-by: Tsubasahane <wozaiha@gmail.com>
Co-authored-by: cake <cake@noreply.git.lightless-sync.org>
Reviewed-on: #123
2026-01-20 19:43:00 +00:00

468 lines
16 KiB
C#

using System;
using LightlessSync.API.Data;
using LightlessSync.API.Data.Enum;
using LightlessSync.API.Dto;
using LightlessSync.API.Dto.CharaData;
using LightlessSync.API.Dto.Chat;
using LightlessSync.API.Dto.Group;
using LightlessSync.API.Dto.User;
using LightlessSync.LightlessConfiguration.Models;
using LightlessSync.Services.Mediator;
using LightlessSync.Utils;
using Microsoft.AspNetCore.SignalR.Client;
using Microsoft.Extensions.Logging;
namespace LightlessSync.WebAPI;
public partial class ApiController
{
public Task Client_DownloadReady(Guid requestId)
{
Logger.LogDebug("Server sent {requestId} ready", requestId);
Mediator.Publish(new DownloadReadyMessage(requestId));
return Task.CompletedTask;
}
public Task Client_GroupChangePermissions(GroupPermissionDto groupPermission)
{
Logger.LogTrace("Client_GroupChangePermissions: {perm}", groupPermission);
ExecuteSafely(() => _pairCoordinator.HandleGroupChangePermissions(groupPermission));
return Task.CompletedTask;
}
public Task Client_GroupChangeUserPairPermissions(GroupPairUserPermissionDto dto)
{
Logger.LogDebug("Client_GroupChangeUserPairPermissions: {dto}", dto);
ExecuteSafely(() => _pairCoordinator.HandleGroupPairPermissions(dto));
return Task.CompletedTask;
}
public Task Client_GroupDelete(GroupDto groupDto)
{
Logger.LogTrace("Client_GroupDelete: {dto}", groupDto);
ExecuteSafely(() => _pairCoordinator.HandleGroupRemoved(groupDto));
return Task.CompletedTask;
}
public Task Client_GroupPairChangeUserInfo(GroupPairUserInfoDto userInfo)
{
Logger.LogTrace("Client_GroupPairChangeUserInfo: {dto}", userInfo);
ExecuteSafely(() =>
{
var isSelf = string.Equals(userInfo.UID, UID, StringComparison.Ordinal);
_pairCoordinator.HandleGroupPairStatus(userInfo, isSelf);
});
return Task.CompletedTask;
}
public Task Client_GroupPairJoined(GroupPairFullInfoDto groupPairInfoDto)
{
Logger.LogTrace("Client_GroupPairJoined: {dto}", groupPairInfoDto);
ExecuteSafely(() => _pairCoordinator.HandleGroupPairJoined(groupPairInfoDto));
return Task.CompletedTask;
}
public Task Client_GroupPairLeft(GroupPairDto groupPairDto)
{
Logger.LogTrace("Client_GroupPairLeft: {dto}", groupPairDto);
ExecuteSafely(() => _pairCoordinator.HandleGroupPairLeft(groupPairDto));
return Task.CompletedTask;
}
public Task Client_GroupSendFullInfo(GroupFullInfoDto groupInfo)
{
Logger.LogTrace("Client_GroupSendFullInfo: {dto}", groupInfo);
ExecuteSafely(() => _pairCoordinator.HandleGroupFullInfo(groupInfo));
return Task.CompletedTask;
}
public Task Client_GroupSendInfo(GroupInfoDto groupInfo)
{
Logger.LogTrace("Client_GroupSendInfo: {dto}", groupInfo);
ExecuteSafely(() => _pairCoordinator.HandleGroupInfoUpdate(groupInfo));
return Task.CompletedTask;
}
public Task Client_ReceiveServerMessage(MessageSeverity messageSeverity, string message)
{
switch (messageSeverity)
{
case MessageSeverity.Error:
Mediator.Publish(new NotificationMessage("Warning from " + _serverManager.CurrentServer!.ServerName, message, NotificationType.Error, TimeSpan.FromSeconds(7.5)));
break;
case MessageSeverity.Warning:
Mediator.Publish(new NotificationMessage("Warning from " + _serverManager.CurrentServer!.ServerName, message, NotificationType.Warning, TimeSpan.FromSeconds(7.5)));
break;
case MessageSeverity.Information:
if (_doNotNotifyOnNextInfo)
{
_doNotNotifyOnNextInfo = false;
break;
}
Mediator.Publish(new NotificationMessage("Info from " + _serverManager.CurrentServer!.ServerName, message, NotificationType.Info, TimeSpan.FromSeconds(5)));
break;
}
return Task.CompletedTask;
}
public Task Client_ReceiveBroadcastPairRequest(UserPairNotificationDto dto)
{
Logger.LogDebug("Client_ReceiveBroadcastPairRequest: {dto}", dto);
if (dto is null)
{
return Task.CompletedTask;
}
ExecuteSafely(() =>
{
Mediator.Publish(new PairRequestReceivedMessage(dto.myHashedCid, dto.message ?? string.Empty));
});
return Task.CompletedTask;
}
public Task Client_UpdateSystemInfo(SystemInfoDto systemInfo)
{
SystemInfoDto = systemInfo;
//Mediator.Publish(new UpdateSystemInfoMessage(systemInfo));
return Task.CompletedTask;
}
public Task Client_ChatReceive(ChatMessageDto message)
{
Logger.LogTrace("Client_ChatReceive: {@channel}", message.Channel);
ExecuteSafely(() => ChatMessageReceived?.Invoke(message));
return Task.CompletedTask;
}
public Task Client_UpdateUserIndividualPairStatusDto(UserIndividualPairStatusDto dto)
{
Logger.LogDebug("Client_UpdateUserIndividualPairStatusDto: {dto}", dto);
ExecuteSafely(() => _pairCoordinator.HandleUserStatus(dto));
return Task.CompletedTask;
}
public Task Client_UserAddClientPair(UserPairDto dto)
{
Logger.LogDebug("Client_UserAddClientPair: {dto}", dto);
ExecuteSafely(() => _pairCoordinator.HandleUserAddPair(dto, addToLastAddedUser: true));
return Task.CompletedTask;
}
public Task Client_UserReceiveCharacterData(OnlineUserCharaDataDto dataDto)
{
Logger.LogTrace("Client_UserReceiveCharacterData: {user}", dataDto.User);
ExecuteSafely(() => _pairCoordinator.HandleCharacterData(dataDto));
return Task.CompletedTask;
}
public Task Client_UserReceiveUploadStatus(UserDto dto)
{
Logger.LogTrace("Client_UserReceiveUploadStatus: {dto}", dto);
ExecuteSafely(() =>
{
_pairCoordinator.HandleUploadStatus(dto);
});
return Task.CompletedTask;
}
public Task Client_UserRemoveClientPair(UserDto dto)
{
Logger.LogDebug("Client_UserRemoveClientPair: {dto}", dto);
ExecuteSafely(() => _pairCoordinator.HandleUserRemovePair(dto));
return Task.CompletedTask;
}
public Task Client_UserSendOffline(UserDto dto)
{
Logger.LogDebug("Client_UserSendOffline: {dto}", dto);
ExecuteSafely(() => _pairCoordinator.HandleUserOffline(dto.User));
return Task.CompletedTask;
}
public Task Client_UserSendOnline(OnlineUserIdentDto dto)
{
Logger.LogDebug("Client_UserSendOnline: {dto}", dto);
ExecuteSafely(() => _pairCoordinator.HandleUserOnline(dto, sendNotification: true));
return Task.CompletedTask;
}
public Task Client_UserUpdateDefaultPermissions(DefaultPermissionsDto dto)
{
Logger.LogDebug("Client_UserUpdateDefaultPermissions: {dto}", dto);
_connectionDto!.DefaultPreferredPermissions = dto;
return Task.CompletedTask;
}
public Task Client_UserUpdateOtherPairPermissions(UserPermissionsDto dto)
{
Logger.LogDebug("Client_UserUpdateOtherPairPermissions: {dto}", dto);
ExecuteSafely(() => _pairCoordinator.HandleUserPermissions(dto));
return Task.CompletedTask;
}
public Task Client_UserUpdateProfile(UserDto dto)
{
Logger.LogDebug("Client_UserUpdateProfile: {dto}", dto);
ExecuteSafely(() => Mediator.Publish(new ClearProfileUserDataMessage(dto.User)));
return Task.CompletedTask;
}
public Task Client_GroupSendProfile(GroupProfileDto groupInfo)
{
Logger.LogDebug("Client_GroupSendProfile: {dto}", groupInfo);
ExecuteSafely(() => Mediator.Publish(new ClearProfileGroupDataMessage(groupInfo.Group)));
return Task.CompletedTask;
}
public Task Client_UserUpdateSelfPairPermissions(UserPermissionsDto dto)
{
Logger.LogDebug("Client_UserUpdateSelfPairPermissions: {dto}", dto);
ExecuteSafely(() => _pairCoordinator.HandleSelfPermissions(dto));
return Task.CompletedTask;
}
public Task Client_GposeLobbyJoin(UserData userData)
{
Logger.LogDebug("Client_GposeLobbyJoin: {dto}", userData);
ExecuteSafely(() => Mediator.Publish(new GposeLobbyUserJoin(userData)));
return Task.CompletedTask;
}
public Task Client_GposeLobbyLeave(UserData userData)
{
Logger.LogDebug("Client_GposeLobbyLeave: {dto}", userData);
ExecuteSafely(() => Mediator.Publish(new GPoseLobbyUserLeave(userData)));
return Task.CompletedTask;
}
public Task Client_GposeLobbyPushCharacterData(CharaDataDownloadDto charaDownloadDto)
{
Logger.LogDebug("Client_GposeLobbyPushCharacterData: {dto}", charaDownloadDto.Uploader);
ExecuteSafely(() => Mediator.Publish(new GPoseLobbyReceiveCharaData(charaDownloadDto)));
return Task.CompletedTask;
}
public Task Client_GposeLobbyPushPoseData(UserData userData, PoseData poseData)
{
Logger.LogDebug("Client_GposeLobbyPushPoseData: {dto}", userData);
ExecuteSafely(() => Mediator.Publish(new GPoseLobbyReceivePoseData(userData, poseData)));
return Task.CompletedTask;
}
public Task Client_GposeLobbyPushWorldData(UserData userData, WorldData worldData)
{
//Logger.LogDebug("Client_GposeLobbyPushWorldData: {dto}", userData);
ExecuteSafely(() => Mediator.Publish(new GPoseLobbyReceiveWorldData(userData, worldData)));
return Task.CompletedTask;
}
public Task Client_SendLocationToClient(LocationDto locationDto, DateTimeOffset expireAt)
{
Logger.LogDebug($"{nameof(Client_SendLocationToClient)}: {locationDto.User} {expireAt}");
ExecuteSafely(() => Mediator.Publish(new LocationSharingMessage(locationDto.User, locationDto.Location, expireAt)));
return Task.CompletedTask;
}
public void OnDownloadReady(Action<Guid> act)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_DownloadReady), act);
}
public void OnGroupChangePermissions(Action<GroupPermissionDto> act)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_GroupChangePermissions), act);
}
public void OnGroupChangeUserPairPermissions(Action<GroupPairUserPermissionDto> act)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_GroupChangeUserPairPermissions), act);
}
public void OnGroupDelete(Action<GroupDto> act)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_GroupDelete), act);
}
public void OnGroupPairChangeUserInfo(Action<GroupPairUserInfoDto> act)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_GroupPairChangeUserInfo), act);
}
public void OnGroupPairJoined(Action<GroupPairFullInfoDto> act)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_GroupPairJoined), act);
}
public void OnGroupPairLeft(Action<GroupPairDto> act)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_GroupPairLeft), act);
}
public void OnGroupSendFullInfo(Action<GroupFullInfoDto> act)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_GroupSendFullInfo), act);
}
public void OnGroupSendInfo(Action<GroupInfoDto> act)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_GroupSendInfo), act);
}
public void OnGroupUpdateProfile(Action<GroupProfileDto> act)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_GroupSendProfile), act);
}
public void OnReceiveServerMessage(Action<MessageSeverity, string> act)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_ReceiveServerMessage), act);
}
public void OnReceiveBroadcastPairRequest(Action<UserPairNotificationDto> act)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_ReceiveBroadcastPairRequest), act);
}
public void OnUpdateSystemInfo(Action<SystemInfoDto> act)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_UpdateSystemInfo), act);
}
public void OnUpdateUserIndividualPairStatusDto(Action<UserIndividualPairStatusDto> action)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_UpdateUserIndividualPairStatusDto), action);
}
public void OnUserAddClientPair(Action<UserPairDto> act)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_UserAddClientPair), act);
}
public void OnUserDefaultPermissionUpdate(Action<DefaultPermissionsDto> act)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_UserUpdateDefaultPermissions), act);
}
public void OnUserReceiveCharacterData(Action<OnlineUserCharaDataDto> act)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_UserReceiveCharacterData), act);
}
public void OnUserReceiveUploadStatus(Action<UserDto> act)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_UserReceiveUploadStatus), act);
}
public void OnUserRemoveClientPair(Action<UserDto> act)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_UserRemoveClientPair), act);
}
public void OnUserSendOffline(Action<UserDto> act)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_UserSendOffline), act);
}
public void OnUserSendOnline(Action<OnlineUserIdentDto> act)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_UserSendOnline), act);
}
public void OnUserUpdateOtherPairPermissions(Action<UserPermissionsDto> act)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_UserUpdateOtherPairPermissions), act);
}
public void OnUserUpdateProfile(Action<UserDto> act)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_UserUpdateProfile), act);
}
public void ClientGroupSendProfile(Action<GroupProfileDto> act)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_GroupSendProfile), act);
}
public void OnUserUpdateSelfPairPermissions(Action<UserPermissionsDto> act)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_UserUpdateSelfPairPermissions), act);
}
public void OnGposeLobbyJoin(Action<UserData> act)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_GposeLobbyJoin), act);
}
public void OnGposeLobbyLeave(Action<UserData> act)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_GposeLobbyLeave), act);
}
public void OnGposeLobbyPushCharacterData(Action<CharaDataDownloadDto> act)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_GposeLobbyPushCharacterData), act);
}
public void OnGposeLobbyPushPoseData(Action<UserData, PoseData> act)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_GposeLobbyPushPoseData), act);
}
public void OnGposeLobbyPushWorldData(Action<UserData, WorldData> act)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_GposeLobbyPushWorldData), act);
}
public void OnReceiveLocation(Action<LocationDto, DateTimeOffset> act)
{
if (_initialized) return;
_lightlessHub!.On(nameof(Client_SendLocationToClient), act);
}
private void ExecuteSafely(Action act)
{
try
{
act();
}
catch (Exception ex)
{
Logger.LogCritical(ex, "Error on executing safely");
}
}
}