Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class HTTPManager
// NOTE: set bDisableServiceAuth for endpoints that must be called with something other than the session token (e.g. the refresh endpoint, which needs the refresh token), otherwise the session token overwrites any Authorization header passed in inHeaders
void SendPOSTRequest(const char* szURI, EIPProtocolVersion protover, std::map<std::string, std::string>& inHeaders, const char* szPostData, std::function<void(bool bSuccess, int statusCode, std::string strBody, HTTPRequest* pReq)> completionCallback, std::function<void(size_t bytesReceived)> progressCallback = nullptr, int timeoutMS = -1, bool bDisableServiceAuth = false);
void SendPUTRequest(const char* szURI, EIPProtocolVersion protover, std::map<std::string, std::string>& inHeaders, const char* szData, std::function<void(bool bSuccess, int statusCode, std::string strBody, HTTPRequest* pReq)> completionCallback, std::function<void(size_t bytesReceived)> progressCallback = nullptr, int timeoutMS = -1);
void SendS3PUTRequest(const char* szURI, EIPProtocolVersion protover, std::map<std::string, std::string>& inHeaders, std::vector<uint8_t> vecBuffer, std::function<void(bool bSuccess, int statusCode, std::string strBody, HTTPRequest* pReq)> completionCallback, std::function<void(size_t bytesReceived)> progressCallback = nullptr, int timeoutMS = -1);
void SendS3PUTRequest(const char* szURI, EIPProtocolVersion protover, std::map<std::string, std::string>& inHeaders, std::vector<uint8_t> vecBuffer, std::function<void(bool bSuccess, int statusCode, std::string strBody, HTTPRequest* pReq)> completionCallback, std::function<void(size_t bytesReceived)> progressCallback = nullptr, int timeoutMS = -1, int maxSendBytesPerSec = 0);
void SendDELETERequest(const char* szURI, EIPProtocolVersion protover, std::map<std::string, std::string>& inHeaders, const char* szData, std::function<void(bool bSuccess, int statusCode, std::string strBody, HTTPRequest* pReq)> completionCallback, std::function<void(size_t bytesReceived)> progressCallback = nullptr, int timeoutMS = -1);

void Shutdown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ class HTTPRequest
m_bAppendAuthIfPresent = false;
}

void SetMaxSendSpeed(int bytesPerSec)
{
m_maxSendBytesPerSec = bytesPerSec;
}

void OnResponsePartialWrite(std::uint8_t* pBuffer, size_t numBytes);

bool HasStarted() const { return m_bIsStarted; }
Expand Down Expand Up @@ -77,6 +82,8 @@ class HTTPRequest

bool m_bAppendAuthIfPresent = true;

int m_maxSendBytesPerSec = 0; // 0 = unlimited

EIPProtocolVersion m_protover;

int m_timeoutMS = 5000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <thread>
#include <memory>
#include <chrono>

class HTTPManager;

Expand All @@ -28,6 +29,7 @@ struct S3ScreenshotEntry
std::vector<uint8_t> vecBytes;
std::string strSignedURI;
EScreenshotType screenshotType;
std::chrono::steady_clock::time_point notBefore; // upload is held back until this time

bool operator==(const S3ScreenshotEntry& other) const
{
Expand Down Expand Up @@ -341,6 +343,8 @@ struct ServiceConfig

int screenshot_width = 557;
int screenshot_height = 333;
int screenshot_upload_bytes_per_sec = 131072; // 128 KB/s
int screenshot_slot_offset_ms = 2000;

// ICE client used for P2P NAT traversal: 0 = library default, 1 = native, 2 = WebRTC.
int ice_implementation = 2;
Expand All @@ -351,7 +355,7 @@ struct ServiceConfig
ra_slack_percent, frame_grouping_frames, enable_host_migration, network_do_immediate_flush_per_frame, network_send_flags, network_latency_logic_model,
use_default_config, ra_slack_override_percent_in_default, do_probes, do_replay_upload, network_mesh_histogram_duration,
ibra_ra_tweaks, ibra_minslack_default, ibra_maxslack_default, ibra_minslack_greaterthan300ms, ibra_maxslack_greaterthan300ms, ibra_minslack_greaterthan200ms, ibra_maxslack_greaterthan200ms,
screenshot_width, screenshot_height, ice_implementation, use_new_networking)
screenshot_width, screenshot_height, screenshot_upload_bytes_per_sec, screenshot_slot_offset_ms, ice_implementation, use_new_networking)
};

class NGMP_OnlineServicesManager
Expand Down Expand Up @@ -586,10 +590,10 @@ class NGMP_OnlineServicesManager
ServiceConfig& GetServiceConfig() { return m_ServiceConfig; }

public:
void CacheScreenshotBytes_StartMatch(std::vector<uint8_t>& vecData)
void CacheScreenshotBytes_StartMatch(std::vector<uint8_t> vecData)
{
std::scoped_lock<std::mutex> ssLock(m_ScreenshotMutex);
m_vecCachedScreenshotBytes_MatchStart = vecData;
m_vecCachedScreenshotBytes_MatchStart = std::move(vecData);
}

void CacheScreenshotBytes_EndMatch(uint64_t matchID, std::vector<uint8_t> data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ void HTTPManager::SendPUTRequest(const char* szURI, EIPProtocolVersion protover,
}


void HTTPManager::SendS3PUTRequest(const char* szURI, EIPProtocolVersion protover, std::map<std::string, std::string>& inHeaders, std::vector<uint8_t> vecBuffer, std::function<void(bool bSuccess, int statusCode, std::string strBody, HTTPRequest* pReq)> completionCallback, std::function<void(size_t bytesReceived)> progressCallback /*= nullptr*/, int timeoutMS /*= -1*/)
void HTTPManager::SendS3PUTRequest(const char* szURI, EIPProtocolVersion protover, std::map<std::string, std::string>& inHeaders, std::vector<uint8_t> vecBuffer, std::function<void(bool bSuccess, int statusCode, std::string strBody, HTTPRequest* pReq)> completionCallback, std::function<void(size_t bytesReceived)> progressCallback /*= nullptr*/, int timeoutMS /*= -1*/, int maxSendBytesPerSec /*= 0*/)
{
CHECK_MAIN_THREAD;

HTTPRequest* pRequest = PlatformCreateRequest(EHTTPVerb::HTTP_VERB_PUT, protover, szURI, inHeaders, completionCallback, progressCallback, timeoutMS);
pRequest->DisableServiceAuth();
pRequest->SetPostDataBuffer(vecBuffer);
pRequest->SetMaxSendSpeed(maxSendBytesPerSec);
pRequest->SetPostDataBuffer(std::move(vecBuffer));

m_vecRequestsPendingStart.push_back(pRequest);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ void HTTPRequest::PlatformStartRequest()
}
}

if (m_maxSendBytesPerSec > 0)
{
curl_easy_setopt(m_pCURL, CURLOPT_MAX_SEND_SPEED_LARGE, (curl_off_t)m_maxSendBytesPerSec);
}

// needed for PUT etc
if (m_httpVerb == EHTTPVerb::HTTP_VERB_PUT)
{
Expand Down
Loading
Loading