Monday, 24 April 2017

Yielding on UnityWebRequest's 'Send()' makes two calls instead of just one

I have already searched, but maybe just couldn't find the right words. The point is, I'm doing requests to a nodejs/express through Unity/C# using UnityWebRequest on a Coroutine and it always send two requests as the server always print 'request received' twice.

//UNITY C# REQUEST
IEnumerator RequestRoutine () {
    using ( UnityWebRequest req = UnityWebRequest.Get ( "http://localhost:8080/blablabla" ) ) {
        yield return req.Send ();

        yield return req.isDone;
        Debug.Log ( "is done" );
    }
}

//NODE.JS server
app.get('/blablabla', (req, res) => {
    console.log('request received')
    res.end()
})



via Raul Thunderbird

No comments:

Post a Comment