ITADN

Update pollNotifications to avoid sending query

#49Pull Requestjgdavey 创建于 2025-03-04
J
jgdaveycommented
Since this method was already of questionable value (especially given the recent improvements to listen/notify handling in #45 ), changing its implementation seems worthwhile. The main idea here is to avoid sending an unnecessary request to the server. Instead, if there is unhandled messages on the read side of things, they are almost definitely asynchronous things (notifications or notices). The spec does allow ParameterStatus to come asynchronously as well. If, somehow, the connection is in such a strange state that we didn't previously wait for the "ready" message, then those unread messages (data or otherwise) will show up here and throw an exception. Although, an argument could be made that they would throw an exception the next time a normal query were to occur. Even if unnecessary or exceedingly rare, including these message IServerMessage instance checks is intention-revealing: we never expect anything except one of these kinds of asynchronous messages to be on the input buffer outside of a query "request/response". I've tested and can confirm this works with regular sockets and unix domain sockets.
合并状态:未合并 关闭于 2025-03-18 2 条评论