private async void RejectConnection(WebSocket socket, string reason, string ip) { Console.WriteLine(String.Format("[{2}] Connection Aborted ({0}): {1}.", ip, reason, DateTime.Now.ToShortTimeString())); var rejection = new LoginRejected() { RejectionMessage = reason }; await ConnectionMessageHandler.HandleMessage(socket, rejection); await socket.CloseAsync(WebSocketCloseStatus.PolicyViolation, reason, CancellationToken.None); }
private Tuple<SqlConnection, ConnectionMessageHandler> CreateConnection(object context) { var connection = new SqlConnection(mConnectionString) { FireInfoMessageEventOnUserErrors = true }; var handler = new ConnectionMessageHandler(this, context); connection.InfoMessage += handler.OnInfoMessage; connection.Open(); return Tuple.Create(connection, handler); }