Fixed webcommand bug
This commit is contained in:
parent
6fcfe5fc21
commit
a91556c949
3 changed files with 17 additions and 6 deletions
|
|
@ -33,6 +33,7 @@ namespace MosswartMassacre
|
|||
private static CancellationTokenSource _cts;
|
||||
private static bool _enabled;
|
||||
private static readonly SemaphoreSlim _sendLock = new SemaphoreSlim(1, 1);
|
||||
private static readonly SynchronizationContext _uiCtx = SynchronizationContext.Current;
|
||||
|
||||
/// <summary>
|
||||
/// Fires when a valid CommandEnvelope arrives for this character.
|
||||
|
|
@ -134,7 +135,17 @@ namespace MosswartMassacre
|
|||
CoreManager.Current.CharacterFilter.Name,
|
||||
StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
OnServerCommand?.Invoke(env);
|
||||
_uiCtx.Post(_ =>
|
||||
{
|
||||
try
|
||||
{
|
||||
OnServerCommand?.Invoke(env); // now on the correct thread
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
PluginCore.WriteToChat($"[CMD] {ex.Message}");
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue