mirror of
https://github.com/pocoproject/poco.git
synced 2025-03-04 19:13:30 +01:00
additonal fix for GH #1212: WebSocketImpl::available() now reports number of bytes in internal buffer.
This commit is contained in:
parent
675e7f6242
commit
7f17dfcc83
@ -55,13 +55,13 @@ WebSocketImpl::~WebSocketImpl()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int WebSocketImpl::sendBytes(const void* buffer, int length, int flags)
|
int WebSocketImpl::sendBytes(const void* buffer, int length, int flags)
|
||||||
{
|
{
|
||||||
Poco::Buffer<char> frame(length + MAX_HEADER_LENGTH);
|
Poco::Buffer<char> frame(length + MAX_HEADER_LENGTH);
|
||||||
Poco::MemoryOutputStream ostr(frame.begin(), frame.size());
|
Poco::MemoryOutputStream ostr(frame.begin(), frame.size());
|
||||||
Poco::BinaryWriter writer(ostr, Poco::BinaryWriter::NETWORK_BYTE_ORDER);
|
Poco::BinaryWriter writer(ostr, Poco::BinaryWriter::NETWORK_BYTE_ORDER);
|
||||||
|
|
||||||
if (flags == 0) flags = WebSocket::FRAME_BINARY;
|
if (flags == 0) flags = WebSocket::FRAME_BINARY;
|
||||||
flags &= 0xff;
|
flags &= 0xff;
|
||||||
writer << static_cast<Poco::UInt8>(flags);
|
writer << static_cast<Poco::UInt8>(flags);
|
||||||
@ -105,7 +105,7 @@ int WebSocketImpl::sendBytes(const void* buffer, int length, int flags)
|
|||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int WebSocketImpl::receiveHeader(char mask[4], bool& useMask)
|
int WebSocketImpl::receiveHeader(char mask[4], bool& useMask)
|
||||||
{
|
{
|
||||||
char header[MAX_HEADER_LENGTH];
|
char header[MAX_HEADER_LENGTH];
|
||||||
@ -318,7 +318,7 @@ void WebSocketImpl::shutdownSend()
|
|||||||
_pStreamSocketImpl->shutdownSend();
|
_pStreamSocketImpl->shutdownSend();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void WebSocketImpl::shutdown()
|
void WebSocketImpl::shutdown()
|
||||||
{
|
{
|
||||||
_pStreamSocketImpl->shutdown();
|
_pStreamSocketImpl->shutdown();
|
||||||
@ -375,8 +375,12 @@ Poco::Timespan WebSocketImpl::getReceiveTimeout()
|
|||||||
|
|
||||||
int WebSocketImpl::available()
|
int WebSocketImpl::available()
|
||||||
{
|
{
|
||||||
return _pStreamSocketImpl->available();
|
int n = _buffer.size() - _bufferOffset;
|
||||||
|
if (n > 0)
|
||||||
|
return n + _pStreamSocketImpl->available();
|
||||||
|
else
|
||||||
|
return _pStreamSocketImpl->available();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} } // namespace Poco::Net
|
} } // namespace Poco::Net
|
||||||
|
Loading…
x
Reference in New Issue
Block a user