|
Twitch SDK (Internal)
|
#include <socket.h>
Public Member Functions | |
| BufferedSocket () | |
| ~BufferedSocket () | |
| void | Bind (const std::shared_ptr< ISocket > &socket) |
| TTV_ErrorCode | Connect () |
| TTV_ErrorCode | Disconnect () |
| TTV_ErrorCode | Send (const uint8_t *buffer, size_t length, bool cache) |
| TTV_ErrorCode | Recv (uint8_t *buffer, size_t length, size_t &received, uint64_t maxWaitForBufferFill) |
| TTV_ErrorCode | FlushCache () |
| TTV_ErrorCode | SetBlockingMode (bool blockingMode) |
| uint64_t | TotalSent () |
| uint64_t | TotalReceived () |
| TTV_ErrorCode | GetAverageSendBitRate (uint64_t measurementWindow, uint64_t &bitsPerSecond) const |
| TTV_ErrorCode | GetCongestionLevel (uint64_t measurementWindow, double &congestionLevel) const |
| bool | Connected () |
Private Member Functions | |
| TTV_ErrorCode | DoSend (const uint8_t *buffer, size_t length) |
Private Attributes | |
| std::shared_ptr< ISocket > | mSocket |
| uint64_t | mLastFlushTime |
| size_t | mCachePos |
| std::array< uint8_t, kMaxBufferSize > | mCache |
| SocketTracker | mTracker |
| bool | mBlocking |
Static Private Attributes | |
| static const size_t | kMaxBufferSize = 0x10000 |
A helper class which wraps an ISocket and handles buffering of sent data. This is useful when sending lots of tiny packets since calling send has a lot of overhead.
| ttv::BufferedSocket::BufferedSocket | ( | ) |
| ttv::BufferedSocket::~BufferedSocket | ( | ) |
| void ttv::BufferedSocket::Bind | ( | const std::shared_ptr< ISocket > & | socket | ) |
| TTV_ErrorCode ttv::BufferedSocket::Connect | ( | ) |
| bool ttv::BufferedSocket::Connected | ( | ) |
| TTV_ErrorCode ttv::BufferedSocket::Disconnect | ( | ) |
|
private |
| TTV_ErrorCode ttv::BufferedSocket::FlushCache | ( | ) |
| TTV_ErrorCode ttv::BufferedSocket::GetAverageSendBitRate | ( | uint64_t | measurementWindow, |
| uint64_t & | bitsPerSecond | ||
| ) | const |
Computes the average sending bit rate in bits per second over a sliding window.
| TTV_ErrorCode ttv::BufferedSocket::GetCongestionLevel | ( | uint64_t | measurementWindow, |
| double & | congestionLevel | ||
| ) | const |
Gives the congestion level, indicating what fraction of time is being spent waiting on sends
| TTV_ErrorCode ttv::BufferedSocket::Recv | ( | uint8_t * | buffer, |
| size_t | length, | ||
| size_t & | received, | ||
| uint64_t | maxWaitForBufferFill | ||
| ) |
| TTV_ErrorCode ttv::BufferedSocket::Send | ( | const uint8_t * | buffer, |
| size_t | length, | ||
| bool | cache | ||
| ) |
Sends the data over the socket, caching locally if the cache flag is set. If the cache is full or the the data has been cached for long enough a flush will happen automatically. maxWaitForSend will be used in the case where TTV_EC_SOCKET_EWOULDBLOCK comes back from the socket and we want to try sending again automatically.
| TTV_ErrorCode ttv::BufferedSocket::SetBlockingMode | ( | bool | blockingMode | ) |
| uint64_t ttv::BufferedSocket::TotalReceived | ( | ) |
| uint64_t ttv::BufferedSocket::TotalSent | ( | ) |
|
staticprivate |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
1.8.13