Example #1
0
 public void initializeVKApi(string key = "")
 {
     if (!String.IsNullOrEmpty(key))
     {
         privateKey = key;
     }
     if (initialized)
     {
         Debug2.LogWarning("vk api already initialized, init method will be ignored");
     }
     else
     {
         initialized  = true;
         callbackPool = CallbackPool.instance;
         callbackPool.initialize();
         initVKApi(privateKey,
                   delegate(object obj, Callback callback){
             inputData = HTTPUtility.ParseQueryString((string)obj);
             Debug2.LogDebug("viewer id =" + inputData["viewer_id"]);
             callbackPool.releaseDisposableCallback(callbackOnInitError);
             if (onApiReady != null)
             {
                 onApiReady(true);
             }
             Debug2.LogDebug("VK api is ready");
         },
                   delegate(object obj, Callback callback){
             onApiReady(false);
             callbackPool.releaseDisposableCallback(callBackOnInitDone);
             Debug2.LogError("problem with vk initialization\n" + Json.Serialize(obj));
         });
     }
 }
    public Callback createNewCallback()
    {
        currentPoolSize++;
        if (warningOnCallbackExceedLimit && currentPoolSize >= callbackLimit)
        {
            Debug2.LogWarning("total amount of callback is " + currentPoolSize + "\n" +
                              " probably you forget to destroy some permanent callback \n" +
                              " if you want to increase amount of callback limit change [callbackLimit] in  CallbackPool \n" +
                              " If you want to disable this check, please make  [warningOnCallbackExceedLimit] = false");
        }
        Callback c = new Callback();

        callbackDict.Add(c.id, c);
        return(c);
    }
Example #3
0
    void createNewAblum()
    {
        Dictionary <string, object> paramsObject = new Dictionary <string, object>();

        paramsObject.Add("name", text);

        MRUController.instance.callMailruByObjectMailruListenerAndCallback(
            "mailru.common.photos.createAlbum",
            paramsObject,
            "mailru.common.events.createAlbum",
            delegate(object obj, Callback callback){
            Dictionary <string, object> result = obj as Dictionary <string, object>;
            string status = (string)result["status"];
            if (status.Equals("opened"))
            {
                Debug2.LogDebug("album window has opened");
            }
            else if (status.Equals("closed"))
            {
                Debug2.LogDebug("album window has closed without creation. Need to unsubscribe from event");
                CallbackPool.instance.releasePermanentCallback(callback);
            }
            else if (status.Equals("createSuccess"))
            {
                Debug2.LogDebug("album created id = " + (string)result["aid"] + " Need to unsubscribe from event");
                CallbackPool.instance.releasePermanentCallback(callback);
                if (albumsMetadata != null)
                {
                    getAlbums();
                }
            }
            else
            {
                Debug2.LogWarning("unknown status [" + status + "]");
            }
        });
    }