Пример #1
0
bool PartHandler::startUpload()
{
   TRACE( "PartHandler starting upload%s", "" );

   if ( m_bUseMemoryUpload || ! m_bPartIsFile )
   {
      startMemoryUpload();
   }
   else
   {
      return startFileUpload() != 0;
   }
   return true;
}
void FileTransferWindow::onUploadFileClicked()
{
	if (m_currentRemoteDir.isEmpty())
	{
		// Need to know remote dir
		::MessageBoxA(NULL, "Load remote directory", "Error", MB_ICONERROR);
		return;
	}

	// Get current selected file
	QModelIndex index = ui.tvDirLocal->currentIndex();
	if (!index.isValid() || !m_fileSystemModel->fileInfo(index).isFile())
	{
		// Nothing or directory were selected
		::MessageBoxA(NULL, "Select local file", "Error", MB_ICONERROR);
		return;
	}
	std::wstring absolutePathUTF16 = std::wstring((wchar_t*)m_fileSystemModel->fileInfo(index).absoluteFilePath().unicode(), m_fileSystemModel->fileInfo(index).absoluteFilePath().length());
	startFileUpload(absolutePathUTF16);
}
    void IBrainCloudComms::filterIncomingMessages(const ServerCall* servercall, const Json::Value& response)
    {
        //This is a hook to perform processing on any messages that come in, before they are sent to the calling application.

        if (servercall->getService() == ServiceName::AuthenticateV2 && servercall->getOperation() == ServiceOperation::Authenticate)
        {
            _isAuthenticated = true;
            setCredentials(response);
            
            // pick up the timeout interval from the auth call
            if (_heartbeatInterval == 0)
            {
                if (response["data"] != Json::nullValue && response["data"]["playerSessionExpiry"] != Json::nullValue)
                {
                    int sessionTimeout = response["data"]["playerSessionExpiry"].asInt();
                    sessionTimeout = (int)(sessionTimeout * 0.85);
                    if (sessionTimeout > 30) // minimum 30 secs
                    {
                        _heartbeatInterval = sessionTimeout * 1000;
                    }
                }
            }
        }
        else if (servercall->getService() == ServiceName::PlayerState
                 && (servercall->getOperation() == ServiceOperation::FullReset
                     || servercall->getOperation() == ServiceOperation::Logout))
        {
            _isAuthenticated = false;
            _sessionId.clear();
            _client->getAuthenticationService()->clearSavedProfileId();
        }
        else if (servercall->getService() == ServiceName::File
                 && (servercall->getOperation() == ServiceOperation::PrepareUserUpload))
        {
            startFileUpload(response);
        }
    }