Example #1
0
 public void StartServer(callBack _cb)
 {
     cb      = _cb;
     sThread = new Thread(new ThreadStart(serverThread));
     sThread.IsBackground = true;
     sThread.Start();
 }
Example #2
0
    IEnumerator JSONRequest(string path, WWWForm variables, callBack callBack)
    {
        WWW urlRequest = new WWW(path, variables);

        yield return(urlRequest); //Wait on url request to come back to us before proceeding

        string jsonFileString = urlRequest.text;

        callBack.Invoke(jsonFileString);
    }
        private void InstallClick(object sender, RoutedEventArgs e) {
            InstallButton.IsEnabled = false;
            btnDone.IsEnabled = false;
            pluginList.IsEnabled = false;
            this.progress.Visibility = Visibility.Visible;
            PluginInstaller p = new PluginInstaller();
            callBack done = new callBack(InstallFinished);
            p.InstallPlugin(pluginList.SelectedItem as IPlugin, progress, this, done);
            MainWindow.Instance.KernelModified = true;

        }
Example #4
0
 public void startConnection(callBack _cb)
 {
     try{
         cb      = _cb;
         cThread = new Thread(new ThreadStart(clientThread));
         cThread.IsBackground = true;
         cThread.Start();
     }
     catch (Exception e) {
         printS(e.ToString());
     }
 }
        private void InstallClick(object sender, RoutedEventArgs e)
        {
            InstallButton.IsEnabled  = false;
            btnDone.IsEnabled        = false;
            pluginList.IsEnabled     = false;
            this.progress.Visibility = Visibility.Visible;
            PluginInstaller p    = new PluginInstaller();
            callBack        done = new callBack(InstallFinished);

            p.InstallPlugin(pluginList.SelectedItem as IPlugin, progress, this, done);
            MainWindow.Instance.KernelModified = true;
        }
Example #6
0
    IEnumerator GetURL(string endpoint, callBack callback)
    {
        //print("in GetURL");
        string url     = baseURL + endpoint + "?access_token=" + accessToken;
        WWW    request = new WWW(url);

        yield return(request);

        JSONObject j = new JSONObject(request.text);

        yield return(j);

        callback(j);
    }
Example #7
0
        public NetConn(callBack cb, string _IP, int _PORT, mode _MODE)
        {
            netMode = _MODE;
            IP      = _IP;
            port    = _PORT;

            if (netMode == mode.HOST)
            {
                _server = new NetServer(IP, port);
                _server.setPWrp(pw);
                _server.StartServer(cb);
            }
            else
            {
                _client = new NetClient(IP, port);
                _client.setPWrp(pw);
                _client.startConnection();
            }
        }
Example #8
0
 void InputButton(ref int button, bool isPush, callBack start, callBack2 upd, callBack end)
 {
     if (isPush)
     {
         if (button == 0)
         {
             start();
         }
         else
         {
             upd(button);
         }
         button++;
     }
     else
     {
         end();
         button = 0;
     }
 }
Example #9
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 #10
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 #11
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 #12
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 #13
0
 public void SetFunction(callBack cb)
 {
     c.Add(cb);
 }
Example #14
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));
 }
Example #15
0
 public void BeginInstall()
 {
     Updater u = new Updater();
     callBack done = new callBack(InstallFinished);
     u.DownloadUpdate(progressBar1, this, done);
 }
 //! let the SharedState call the given function when the registry entry got changed from the server
 public void setUpdateFunction(callBack function)
 {
     cb = function;
 }
 public void BeginInstall(List<IPlugin> plugins)
 {
     PluginInstaller p = new PluginInstaller();
     callBack done = new callBack(InstallFinished);
     p.InstallPlugin(plugins, progressBar1, label1, this, done);
 }
 private void upgradePlugin_Click(object sender, RoutedEventArgs e)
 {
     if (pluginList.SelectedItem != null)
     {
         IPlugin plugin = pluginList.SelectedItem as IPlugin;
         //get our latest version so we can upgrade...
         IPlugin newPlugin = PluginManager.Instance.AvailablePlugins.Find(plugin, PluginManager.Instance.GetLatestVersion(plugin));
         if (newPlugin != null)
         {
             if (!string.IsNullOrEmpty(newPlugin.UpgradeInfo))
             {
                 //confirm upgrade
                 if (MessageBox.Show("This upgrade has the following information:\n\n" + newPlugin.UpgradeInfo + "\n\nDo you still wish to upgrade?", "Upgrade " + plugin.Name, MessageBoxButton.YesNo) == MessageBoxResult.No)
                 {
                     PopUpMsg.DisplayMessage("Upgrade Cancelled");
                     return;
                 }
             }
             PluginInstaller p = new PluginInstaller();
             callBack done = new callBack(UpgradeFinished);
             this.IsEnabled = false;
             p.InstallPlugin(newPlugin, progress, this, done);
             KernelModified = true;
         }
     }
 }
Example #19
0
 public void Call(string endpoint, callBack callback)
 {
     StartCoroutine(GetURL(endpoint, callback));
 }