Ejemplo n.º 1
0
void UOscSettings::Send(const uint8 *buffer, int32 length, int32 targetIndex)
{
    if(targetIndex == -1)
    {
        for(const auto & address : _sendAddresses)
        {
            SendImpl(&_sendSocket.Get(), buffer, length, *address);
        }

#if !NO_LOGGING
        // Log sent packet
        if(!LogOSC.IsSuppressed(ELogVerbosity::Verbose))
        {
            TArray<uint8> tmp;
            tmp.Append(buffer, length);
            const auto encoded = FBase64::Encode(tmp);
            UE_LOG(LogOSC, Verbose, TEXT("SentAll: %s"), *encoded);
        }
#endif
    }
    else if(targetIndex < _sendAddresses.Num())
    {
        SendImpl(&_sendSocket.Get(), buffer, length, *_sendAddresses[targetIndex]);

#if !NO_LOGGING
        // Log sent packet
        if(!LogOSC.IsSuppressed(ELogVerbosity::Verbose))
        {
            TArray<uint8> tmp;
            tmp.Append(buffer, length);
            const auto encoded = FBase64::Encode(tmp);
            const auto target  = _sendAddresses[targetIndex]->ToString(true);
            UE_LOG(LogOSC, Verbose, TEXT("SentTo %s: %s"), *target, *encoded);
        }
#endif
    }
    else
    {
        UE_LOG(LogOSC, Error, TEXT("Cannot send OSC: invalid targetIndex %d"), targetIndex);
    }
}
Ejemplo n.º 2
0
void
HttpRequest::SendAsync ()
{
    char *templ;

    VERIFY_MAIN_THREAD;
    LOG_DOWNLOADER ("HttpRequest::SendAsync () is_aborted: %i is_completed: %i\n", is_aborted, is_completed);

    if (is_aborted || is_completed)
        return;

    /* create tmp file */
    if ((options & DisableFileStorage) == 0) {
        const char *dir = handler->GetDownloadDir ();
        if (dir == NULL) {
            Failed ("Could not create temporary download directory");
            return;
        }

        templ = g_build_filename (dir, "XXXXXX", NULL);
        tmpfile_fd = g_mkstemp (templ);
        if (tmpfile_fd == -1) {
            char *msg = g_strdup_printf ("Could not create temporary download file %s for url %s\n", templ, GetUri ());
            Failed (msg);
            g_free (msg);
            g_free (templ);
            return;
        }
        tmpfile = templ;
        LOG_DOWNLOADER ("HttpRequest::Send () uri %s is being saved to %s\n", GetUri (), tmpfile);
    } else {
        LOG_DOWNLOADER ("HttpRequest::Send () uri %s is not being saved to disk\n", GetUri ());
    }

#if DEBUG
    GetDeployment ()->AddSource (GetOriginalUri (), tmpfile == NULL ? "Not stored on disk" : tmpfile);
#endif

    SendImpl ();
}