diff --git a/BlazorCanvas/BlazorCanvas.Server/Components/Data/CanvasService.cs b/BlazorCanvas/BlazorCanvas.Server/Components/Data/CanvasService.cs index f61f6ab..e0dca97 100644 --- a/BlazorCanvas/BlazorCanvas.Server/Components/Data/CanvasService.cs +++ b/BlazorCanvas/BlazorCanvas.Server/Components/Data/CanvasService.cs @@ -36,18 +36,6 @@ public class CanvasService { public ElementReference divCanvas { get; set; } public BECanvasComponent myCanvas { get; set; } = new(); - /// - /// Version Pub/Sub - /// - public async void Subscribe() { - CancellationToken cToken = new(); - while (!cToken.IsCancellationRequested) { - var comm = await _redisService.Subscribe(cToken); - if (comm is not null) - Draw(comm); - } - } - public async void Consume() { while (!_has_ended) { if (_lsComms.Count > 0) @@ -117,17 +105,13 @@ public class CanvasService { string color = "White"; CanvasCommand command = new(); - mouseX = eventArgs.OffsetX - (pointSize / 2); - mouseY = eventArgs.OffsetY - (pointSize / 2); + // Magnétisme boboche si activé, centrage si pas activé. + mouseX = eventArgs.OffsetX - (!snap? pointSize / 2: mouseX % pointSize); + mouseY = eventArgs.OffsetY - (!snap? pointSize / 2: mouseY % pointSize); if (eventArgs.Buttons == 1) // Couleur si bouton gauche, blanc si bouton droit color = currentColor; - if (snap) { // Magnétisme boboche. - mouseX -= mouseX % pointSize; - mouseY -= mouseY % pointSize; - } - command.X = mouseX; command.Y = mouseY; command.Color = color; @@ -136,7 +120,7 @@ public class CanvasService { if (command.Equals(_lastCommand)) return; // Pour pas spammer des commandes si c'est pas pertinent. - _redisService.Produce(command); // Stream + _redisService.Produce(command); _lastCommand = command; }