} // proc RemoveContext public async Task <IDEAuthentificatedUser> AuthentificateAsync(IIdentity identity) { if (userIdentity == null) // is there a identity { return(null); } if (!userIdentity.Equals(identity)) // check if that the identity matches { return(null); } // check the user information agains the main user var context = CreateContextIntern(identity); // create new context for this identity try { var newConnection = GetOrCreatePooledConnection(application.MainDataSource, context, false); try { // ensure the database connection to the main database if (await newConnection.EnsureConnectionAsync(true)) { return(context); } else { context.Dispose(); return(null); } } catch (Exception e) { log.Except(e); newConnection?.Dispose(); return(null); } } catch (Exception e) { log.Except(e); context.Dispose(); return(null); } } // func Authentificate
} // proc Dispose private async Task Execute() { var recvOffset = 0; var recvBuffer = new byte[1 << 20]; // 1MB buffer try { while (Socket.State == WebSocketState.Open && !cancelSessionTokenSource.IsCancellationRequested) { var recvRest = recvBuffer.Length - recvOffset; // buffer is too small, close connection if (recvRest == 0) { break; } // get bytes var r = await Socket.ReceiveAsync(new ArraySegment <byte>(recvBuffer, recvOffset, recvRest), cancelSessionTokenSource.Token); if (r.MessageType == WebSocketMessageType.Text) // get only text messages { recvOffset += r.Count; if (r.EndOfMessage) // eom { // first decode message try { var xMessage = XElement.Parse(Encoding.UTF8.GetString(recvBuffer, 0, recvOffset)); try { await ProcessMessage(xMessage); } catch (Exception e) { var token = xMessage.GetAttribute("token", 0); if (token > 0) // answer requested { await SendAnswerAsync(xMessage, CreateException(new XElement("exception", new XAttribute("token", token)), e)); } else { throw; // fall to next } } } catch (Exception e) { log.Except(e); } recvOffset = 0; } } } } catch (WebSocketException e) { if (e.WebSocketErrorCode == WebSocketError.ConnectionClosedPrematurely) { log.Except("Debug session closed.", e); } } catch (Exception e) { log.Except("Debug session failed.", e); } finally { Dispose(); } } // proc Execute
public override void SetShouldExit(int exitCode) => log.Except("Exit requested: {0}", exitCode);