Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Networking new WebRequest feedback / questions

Discussion in '5.2 Beta' started by liortal, Jul 7, 2015.

  1. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Hi,

    Trying here as well, as the beta group did not have any responses for this :)

    I have a few comments for the WebRequest object (described here: https://docs.google.com/document/d/1n3EI6xXnhlKQAOCjVNs091hmB7qld6BaNgmSuQr3Ga4/edit)

    * The WebRequest object has "convenience" methods for getting an asset bundle / texture (according to the examples):

    WebRequest.GetTexture ( ... );

    but there's no corresponding convenience method for grabbing the result, which leads to this (ugliness) casting sort of API:



    I understand that the WebRequest object uses the abstract "download handler" concept, but this seems to be unbalanced - providing a simple way to get a texture only for half of the process (initiating the request).

    There could probably be a few different solutions for this, e.g:

    Subclassing WebRequest (e.g: return a TextureWebRequest object whose downloadHandler is of this specific concrete type) or maybe using generics ?

    * Same thing goes for the asset bundle convenience method.

    * The examples for the HLAPI show that you could pass pretty much a URL and that's it (there are default handlers that are attached internally). Are there any overloads for these methods? if so, in case there are many different parameters to be specified, did you consider using a "fluent" API, e.g:

    WebRequest.Get("url").Headers("ddd").WithHandler(handler);

    * when POSTing - you show a method that uses the "legacy" WWWForm object and a newer one (passing a List<IMultipartFormSection).

    1. What is the benefit of using a List over an array in this case ?
    2. The WWWForm object has a few limitations (for example - it cant be enumerated to read back the data from it easily).

    I suppose you chose to keep it for easier migration... IMO for a newer API it's better to not mix up with older APIs. For example, this can be done by defining an extension method that converts a WWWForm into the newer parameter type (e.g: a list of MultipartFormSection) or have a concrete list type have an implicit conversion from a WWWForm.

    * Is this going to be open source? (e.g: checking out how you do all the buffering of downloads for textures, asset bundles, etc) ? is this going to be all implemented in C# ? (please share the code :) )

    Didn't cover the LLAPI part yet, but the most important thing for me is to have mobile support, hope this would be coming soon enough.

    Anyways, looking forward to playing with this new API :)