Merge pull request 'develop' (#20) from develop into master

Reviewed-on: michele/Map#20
This commit is contained in:
michele 2020-12-14 09:58:07 +00:00
commit 9a38a595a7
8 changed files with 93 additions and 39 deletions

View file

@ -20,22 +20,25 @@ steps:
- name: zip
image: alpine:latest
when:
event:
- tag
volumes:
- name: cache
path: /release
commands:
- apk update
- apk add zip
- cd /release/net5.0/win-x64
- zip -r sledgemapper-win.zip ./publish
- mkdir /release/zip
- cp sledgemapper-win.zip /release/zip
- cd /release/net5.0/win-x64
- zip -r sledgemapper-${DRONE_TAG}-win.zip ./publish
- cp sledgemapper-${DRONE_TAG}-win.zip /release/zip
- cd /release/net5.0/osx-x64
- zip -r sledgemapper-osx.zip ./publish
- cp sledgemapper-osx.zip /release/zip
- zip -r sledgemapper-${DRONE_TAG}-osx.zip ./publish
- cp sledgemapper-${DRONE_TAG}-osx.zip /release/zip
- cd /release/net5.0/linux-x64
- zip -r sledgemapper-linux.zip ./publish
- cp sledgemapper-linux.zip /release/zip
- zip -r sledgemapper-${DRONE_TAG}-linux.zip ./publish
- cp sledgemapper-${DRONE_TAG}-linux.zip /release/zip
- name: gitea_release
image: plugins/gitea-release

View file

@ -1,40 +1,50 @@
using System;
using System.Threading.Tasks;
using System.Threading.Channels;
using Exceptionless;
using Exceptionless.Models;
namespace Sledgemapper
{
public class ChannelsQueue
{
private readonly ChannelWriter<Action> _writer;
public ChannelsQueue()
public class ChannelsQueue
{
var channel = Channel.CreateUnbounded<Action>(new UnboundedChannelOptions() { SingleReader = true });
var reader = channel.Reader;
_writer = channel.Writer;
Task.Run(async () =>
{
while (await reader.WaitToReadAsync())
private readonly ChannelWriter<Action> _writer;
public ChannelsQueue()
{
var channel = Channel.CreateUnbounded<Action>(new UnboundedChannelOptions() { SingleReader = true });
var reader = channel.Reader;
_writer = channel.Writer;
Task.Run(async () =>
{
while (await reader.WaitToReadAsync())
{
// Fast loop around available jobs
while (reader.TryRead(out var job))
{
job.Invoke();
{
try
{
job.Invoke();
}
catch (Exception ex)
{
ExceptionlessClient.Default.SubmitException(ex);
throw;
}
}
}
}
});
}
public void Enqueue(Action job)
{
_writer.TryWrite(job);
}
public void Stop()
{
_writer.Complete();
});
}
public void Enqueue(Action job)
{
_writer.TryWrite(job);
}
public void Stop()
{
_writer.Complete();
}
}
}
}

View file

@ -166,6 +166,7 @@ namespace Sledgemapper
{
await Policy
.Handle<ApiException>(ex => ex.StatusCode == HttpStatusCode.RequestTimeout)
.RetryForeverAsync()
//.RetryAsync(Polly.RetrySyntax., async (exception, retryCount) => await Task.Delay(500))
.ExecuteAsync(async () => await call().ConfigureAwait(false))

View file

@ -1,4 +1,5 @@
using System;
using Exceptionless;
namespace Sledgemapper
{
@ -7,6 +8,14 @@ namespace Sledgemapper
[STAThread]
static void Main()
{
ExceptionlessClient.Default.Configuration.ServerUrl = "https://exceptionless.michelescandura.com";
#if DEBUG
ExceptionlessClient.Default.Startup("Qvdn6odZRJyGNnorjayMkiwjVsnAK3rNkFtn9bvL");
#else
ExceptionlessClient.Default.Startup("uprV1LocxAlUPPC9oB4eOlt8jGZ5WypMZKdJCsdL");
#endif
using (var game = new Sledgemapper())
game.Run();
}

View file

@ -1,3 +1,5 @@
using System;
using Exceptionless;
using Microsoft.Xna.Framework;
namespace Sledgemapper
@ -8,13 +10,24 @@ namespace Sledgemapper
public Color OverlayTintColor { get; set; }
public Color GridColor { get; set; }
public Color NoteColor { get; set; }
public string MachineName { get; set; }
public Settings()
{
BackgroundColor=Color.LightGray;
GridColor=Color.Black;
NoteColor=Color.DarkRed;
BackgroundColor = Color.LightGray;
GridColor = Color.Black;
NoteColor = Color.DarkRed;
OverlayTintColor = new Color(24, 118, 157);
try
{
MachineName = Environment.MachineName;
}
catch (Exception ex)
{
ExceptionlessClient.Default.SubmitException(ex);
MachineName = "n/a";
}
}
}
}

View file

@ -1,4 +1,6 @@
using Microsoft.AspNetCore.SignalR.Client;
using Exceptionless;
using Exceptionless.Models;
using Microsoft.AspNetCore.SignalR.Client;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
@ -63,24 +65,28 @@ namespace Sledgemapper
private async Task OnHubDisconnected(Exception arg)
{
ExceptionlessClient.Default.SubmitEvent(new Event { Message = "Hub disconnected", Type = "SignalR Client Events", Source = _settings.MachineName });
_mainWidget.lblConnectionStatus.Text = "Disconnected";
await Task.Yield();
}
private async Task OnHubReconnecting(Exception arg)
{
ExceptionlessClient.Default.SubmitEvent(new Event { Message = "Reconnecting Hub", Type = "SignalR Client Events", Source = _settings.MachineName });
_mainWidget.lblConnectionStatus.Text = "Reconnecting";
await Task.Yield();
}
private async Task OnHubReconnected(string arg)
{
ExceptionlessClient.Default.SubmitEvent(new Event { Message = "Hub reconnected", Type = "SignalR Client Events", Source = _settings.MachineName });
_mainWidget.lblConnectionStatus.Text = "Connected";
await Task.Yield();
}
protected override void Initialize()
{
ExceptionlessClient.Default.SubmitEvent(new Event { Message = "Initialize", Type = "AppLifecycle", Source = _settings.MachineName });
IsMouseVisible = true;
Window.AllowUserResizing = true;
base.Initialize();
@ -891,7 +897,7 @@ namespace Sledgemapper
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
ExceptionlessClient.Default.SubmitException(ex);
}
if (successful)
@ -1006,11 +1012,13 @@ namespace Sledgemapper
}
catch (Refit.ApiException refitException)
{
ExceptionlessClient.Default.SubmitException(refitException);
localContent.LblLoginError.Text = refitException.Content;
localContent.LblLoginError.Visible = true;
}
catch (Exception ex)
{
ExceptionlessClient.Default.SubmitException(ex);
localContent.LblLoginError.Text = "Can't connect to the server";
localContent.LblLoginError.Visible = true;
Debug.Write(ex);
@ -1093,11 +1101,13 @@ namespace Sledgemapper
}
catch (Refit.ApiException refitException)
{
ExceptionlessClient.Default.SubmitException(refitException);
localContent.LblLoginError.Text = refitException.Content;
localContent.LblLoginError.Visible = true;
}
catch (Exception ex)
{
ExceptionlessClient.Default.SubmitException(ex);
localContent.LblLoginError.Text = "Can't connect to the server";
localContent.LblLoginError.Visible = true;
Debug.Write(ex);

View file

@ -42,6 +42,7 @@
</ItemGroup> -->
<ItemGroup>
<PackageReference Include="AsyncAwaitBestPractices" Version="5.0.2" />
<PackageReference Include="exceptionless" Version="4.5.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.0.1641" />
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.0.1641" />

7
nuget.config Normal file
View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="BaGet" value="https://baget.michelescandura.com/v3/index.json" />
</packageSources>
</configuration>