private bool PostgresMessageRead(out IPostgresMessage message) { while (true) { var foundMessage = PostgresMessage.ReadMessage( _buffer, ref _bufferOffset, ref _bufferCount, ref _readState, ref ClientState, out message); if (foundMessage) { // https://www.postgresql.org/docs/10/static/protocol-flow.html#PROTOCOL-ASYNC // TODO: Handle 'LISTEN' switch (message) { case ErrorResponseMessage errorMessage: throw new PostgresErrorException(errorMessage); case NoticeResponseMessage noticeMessage: NoticeResponse?.Invoke( this, noticeMessage.PublicCloneNotices()); continue; case ParameterStatusMessage paramMessage: ClientState.SetParameter(paramMessage); continue; } } return(foundMessage); } }
private static string Describe(IPostgresMessage message) { return($"Message type {message.GetType()} not expected at this time."); }
internal PostgresInvalidMessageException( IPostgresMessage message, string description) : base($"{Describe(message)} {description}") { }
internal PostgresInvalidMessageException(IPostgresMessage message) : base(Describe(message)) { }