Example #1
0
 /// <summary>
 /// The TextInput constructor
 /// </summary>
 /// <param name="name">name of the component</param>
 /// <param name="drawInfo">Drawing info about the text component</param>
 /// <param name="inputActionCallBack">The function to be called whence enter is pressed.</param>
 public TextInputComponent(string name, DrawableComponent
                           drawInfo, stringCallBack inputActionCallBack)
     : base(name, drawInfo)
 {
     _sCurrentInput       = "";
     _inputActionCallBack = inputActionCallBack;
 }
Example #2
0
 /// <summary>
 /// The TextInput constructor
 /// </summary>
 /// <param name="name">name of the component</param>
 /// <param name="drawInfo">Drawing info about the text component</param>
 /// <param name="inputActionCallBack">The function to be called whence enter is pressed.</param>
 public TextInputComponent(string name, DrawableComponent
     drawInfo, stringCallBack inputActionCallBack)
     : base(name, drawInfo)
 {
     _sCurrentInput = "";
     _inputActionCallBack = inputActionCallBack;
 }
Example #3
0
    Monitor AddFile(string _url, callBack _ok = null, stringCallBack _error = null, string _json = "")
    {
        m_pending++;
        gameObject.SetActive(true);
        if (m_postData == null)
        {
            m_postData = System.Text.UTF8Encoding.UTF8.GetBytes("pragma=no-cache");
        }
        WWW www;

        if (_json != string.Empty)
        {
            www = new WWW(_url, UTF8Encoding.UTF8.GetBytes(_json), m_header);
        }
        else
        {
            www = new WWW(_url, m_postData, m_header);
        }
        Monitor m = new Monitor(www);

        StartCoroutine(DowloadFile(www, _ok, _error, m));
        return(m);
    }
Example #4
0
 /// <summary>
 /// Añade un fichero al gestor de descargas.
 /// </summary>
 /// <param name="_url">Url de descarga o path relativo al servidor de media. Si se usa el path, debe empezar por '/'</param>
 /// <param name="_ok">delegado(object _ret) ejecutado si descarga se efectuo correctamente.</param>
 /// <param name="_error">delegado(string _ret) ejecutado si descarga se efectuo incorrectamente.</param>
 /// <returns>retorna un monitor para poder </returns>
 public Monitor getMediaFile(string _url, callBack _ok = null, stringCallBack _error = null)
 {
     return(AddFile(_url[0] == '/' ? mediaURL + _url : _url, _ok, _error));
 }
Example #5
0
 /// <summary>
 /// Realiza una petición GET / POST
 /// Nota: Si el (_form != null) entonces el paso de parametros es por POST, si (_form == null) entonces el paso de parametros es por GET y hay que
 /// pasar los parametros en la "_url"
 /// </summary>
 /// <param name="_url">Url o path relativo al servidor de servicios web. Si se usa el path, debe empezar por '/'</param>
 /// <param name="_ok">delegado(object _ret) ejecutado si descarga se efectuo correctamente.</param>
 /// <param name="_error">delegado(string _ret) ejecutado si descarga se efectuo incorrectamente.</param>
 /// <returns>retorna un monitor para poder </returns>
 public Monitor callWS(string _url, callBack _ok = null, stringCallBack _error = null, string _json = "")
 {
     return(AddFile(_url[0] == '/' ? baseURL + _url : _url, _ok, _error, _json));
 }
Example #6
0
    IEnumerator DowloadFile(WWW _www, callBack _ok, stringCallBack _error, Monitor _monitor)
    {
        yield return(_www);

        if (!_monitor.disposed)
        {
            if (_www.error == null)
            {
                try {
                    byte[] res = _www.bytes;
#if SHOW_DATA
                    foreach (var pair in _www.responseHeaders)
                    {
                        Debug.Log(pair.Key + ": " + pair.Value);
                    }
#endif
                    if (_www.responseHeaders.ContainsKey("CONTENT-ENCODING") && _www.responseHeaders["CONTENT-ENCODING"] == "gzip")
                    {
                        res = Ionic.Zlib.GZipStream.UncompressBuffer(res);
                    }

                    if (_ok != null)
                    {
                        if (_www.responseHeaders.ContainsKey("CONTENT-TYPE"))
                        {
                            string[] type = _www.responseHeaders["CONTENT-TYPE"].Split(';');
                            switch (type[0])
                            {
                            case "image/jpeg":
                            case "image/png":
                                Texture2D txt = _www.texture;
                                txt.name = "downloaded";
                                if (_ok != null)
                                {
                                    _ok(txt);
                                }
                                break;

                            case "application/json":
                                if (_ok != null)
                                {
                                    _ok((IDictionary)MiniJSON.Json.Deserialize(System.Text.UTF8Encoding.UTF8.GetString(res)));
                                }
                                break;

                            case "text/plain":
                            default:
                                if (_ok != null)
                                {
                                    _ok(System.Text.UTF8Encoding.UTF8.GetString(res));
                                }
                                break;
                            }
                        }
                    }
                } catch (System.Exception _e) {
                    if (_error != null)
                    {
                        _error(_www.error + _e.ToString());
                    }
                }
            }
            else
            if (_error != null)
            {
                _error(_www.error + "  (" + _www.url + ")");
            }
        }
        _monitor.Dispose();
        _www.Dispose();
        m_pending--;
        if (m_pending == 0)
        {
            gameObject.SetActive(false);
        }
    }
Example #7
0
 /// <summary>
 /// Realiza una petición GET / POST
 /// Nota: Si el (_form != null) entonces el paso de parametros es por POST, si (_form == null) entonces el paso de parametros es por GET y hay que
 /// pasar los parametros en la "_url"
 /// </summary>
 /// <param name="_url">Url o path relativo al servidor de servicios web. Si se usa el path, debe empezar por '/'</param>
 /// <param name="_ok">delegado(object _ret) ejecutado si descarga se efectuo correctamente.</param>
 /// <param name="_error">delegado(string _ret) ejecutado si descarga se efectuo incorrectamente.</param>
 /// <returns>retorna un monitor para poder </returns>
 public Monitor callWS(string _url, callBack _ok = null, stringCallBack _error = null, WWWForm _form = null)
 {
     return(AddFile(_url[0] == '/' ? baseURL + _url : _url, _ok, _error, _form));
 }