diff --git a/Ooui/UI.cs b/Ooui/UI.cs index 3071a18..add80c6 100644 --- a/Ooui/UI.cs +++ b/Ooui/UI.cs @@ -530,7 +530,7 @@ namespace Ooui // Create a new session and let it handle everything from here // try { - var session = new WebSocketSession (element, disposeElementWhenDone, w, h, Error, serverToken); + var session = new WebSocketSession (this,element, disposeElementWhenDone, w, h, Error, serverToken); listenerContext.StartWebSocketConnection(session.Opened, session.Arrived, session.Closed); } diff --git a/Ooui/WebSocketSession.cs b/Ooui/WebSocketSession.cs index 4abb22d..e4fca77 100644 --- a/Ooui/WebSocketSession.cs +++ b/Ooui/WebSocketSession.cs @@ -24,11 +24,11 @@ namespace Ooui DateTime lastTransmitTime = DateTime.MinValue; readonly TimeSpan throttleInterval = TimeSpan.FromSeconds (1.0 / UI.MaxFps); - public WebSocketSession (Element element, bool disposeElementAfterSession, double initialWidth, double initialHeight, Action errorLogger, CancellationToken serverToken) + public WebSocketSession (UI ui,Element element, bool disposeElementAfterSession, double initialWidth, double initialHeight, Action errorLogger, CancellationToken serverToken) : base (element, disposeElementAfterSession, initialWidth, initialHeight, errorLogger) { - + this.ui = ui; // // Create a new session cancellation token that will trigger // automatically if the server shutsdown or the session shutsdown. @@ -110,6 +110,19 @@ namespace Ooui } } + catch ( System.AggregateException ex) + { + if(ex.ToString().Replace(" ","").ToLower().Contains("mutexisnotowned")) + { + if(ui.Verbose) + Console.WriteLine("Mutex is not owned error, continue going"); + }else{ + Error ("Failed to send queued messages, aborting session", ex); + element.MessageSent -= handleElementMessageSent; + sessionCts.Cancel (); + } + _=ex; + } catch (Exception ex) { Error ("Failed to send queued messages, aborting session", ex); element.MessageSent -= handleElementMessageSent; @@ -122,6 +135,7 @@ namespace Ooui sendMsg = arg1; Init(); } + internal UI ui; internal void Arrived(WebSocketMessage obj) {