public bool TryGetValue(string key, out TOut value)
        {
            TIn  outValue;
            bool result = toWrap.TryGetValue(key, out outValue);

            value = (TOut)AVClient.ConvertTo <TOut>(outValue);
            return(result);
        }
 public TOut this[string key] {
     get {
         return((TOut)AVClient.ConvertTo <TOut>(toWrap[key]));
     }
     set {
         toWrap[key] = (TIn)AVClient.ConvertTo <TIn>(value);
     }
 }
 public IEnumerator <KeyValuePair <string, TOut> > GetEnumerator()
 {
     foreach (var pair in toWrap)
     {
         yield return(new KeyValuePair <string, TOut>(pair.Key,
                                                      (TOut)AVClient.ConvertTo <TOut>(pair.Value)));
     }
 }
 public TOut this[int index] {
     get {
         return((TOut)AVClient.ConvertTo <TOut>(toWrap[index]));
     }
     set {
         toWrap[index] = (TIn)AVClient.ConvertTo <TIn>(value);
     }
 }
Ejemplo n.º 5
0
 public void SetUp()
 {
     AVClient.Initialize(new AVClient.Configuration
     {
         ApplicationId  = "",
         ApplicationKey = ""
     });
 }
        public void CopyTo(KeyValuePair <string, TOut>[] array, int arrayIndex)
        {
            var converted = from pair in toWrap
                            select new KeyValuePair <string, TOut>(pair.Key,
                                                                   (TOut)AVClient.ConvertTo <TOut>(pair.Value));

            converted.ToList().CopyTo(array, arrayIndex);
        }
Ejemplo n.º 7
0
        internal static AVRealtime NewRealtime()
        {
            Websockets.Net.WebsocketConnection.Link();
            var appId  = "Eohx7L4EMfe4xmairXeT7q1w-gzGzoHsz";
            var appKey = "GSBSGpYH9FsRdCss8TGQed0F";

            AVClient.Initialize(appId, appKey);
            return(new AVRealtime(appId, appKey));
        }
Ejemplo n.º 8
0
        public void SetUp()
        {
            string appId  = ConfigurationManager.AppSettings["appId"];
            string appKey = ConfigurationManager.AppSettings["appKey"];

            AVClient.Initialize(appId, appKey);

            AVUser.LogOut();
        }
Ejemplo n.º 9
0
 public virtual void SetUp()
 {
     AVClient.Initialize("315XFAYyIGPbd98vHPCBnLre-9Nh9j0Va", "Y04sM6TzhMSBmCMkwfI3FpHc");
     Websockets.Net.WebsocketConnection.Link();
     Play.Logger = (message) =>
     {
         Trace.WriteLine(message);
     };
 }
Ejemplo n.º 10
0
        Task <Tuple <HttpStatusCode, string> > PutChunk(FileState state, byte[] chunkBinary, string LastChunkctx, long currentChunkOffsetInBlock)
        {
            MemoryStream chunkData = new MemoryStream(chunkBinary, 0, chunkBinary.Length);

            return(AVClient.RequestAsync(new Uri(new Uri(UP_HOST) + string.Format("bput/{0}/{1}", LastChunkctx,
                                                                                  currentChunkOffsetInBlock)), "POST",
                                         GetQiniuRequestHeaders(state), chunkData,
                                         "application/octet-stream", CancellationToken.None));
        }
Ejemplo n.º 11
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            //初始化云服务器
            AVClient.Initialize("EthsHELtLfXL9XBqcFfzMrPO-gzGzoHsz", "xODJ808fAD8hpLHlblQhk0t1", "https://ethshelt.lc-cn-n1-shared.com");

            Login login = new Login();

            login.Show();
        }
    public void CallLocalEngine()
    {
        AVClient.HttpLog(Debug.Log);

        AVCloud.CallFunctionAsync <string>("hello", null).ContinueWith(t =>
        {
            Debug.Log(t.Result);
        });
    }
        public void Conversation_Send_Image_Message()
        {
            AVClient.Initialize("uay57kigwe0b6f5n0e1d4z4xhydsml3dor24bzwvzr57wdap", "kfgz7jjfsk55r5a8a3y4ttd3je1ko11bkibcikonk32oozww");
            var client = new AVIMClient("Tom");

            client.ConnectAsync().ContinueWith(_ =>
            {
                AVIMImageMessage message = AVIMImageMessage.FromUrl("http://ww3.sinaimg.cn/bmiddle/596b0666gw1ed70eavm5tg20bq06m7wi.gif");
            }).Wait();
        }
Ejemplo n.º 14
0
        public object Apply(object oldValue, string key)
        {
            if (oldValue == null)
            {
                return(objects.ToList());
            }
            var oldList = (IList <object>)AVClient.ConvertTo <IList <object> >(oldValue);

            return(oldList.Concat(objects).ToList());
        }
Ejemplo n.º 15
0
 public AVIMMessageNotice(IDictionary <string, object> estimatedData)
     : base(estimatedData)
 {
     this.cid        = estimatedData["cid"].ToString();
     this.fromPeerId = estimatedData["fromPeerId"].ToString();
     this.id         = estimatedData["id"].ToString();
     this.appId      = estimatedData["appId"].ToString();
     this.peerId     = estimatedData["peerId"].ToString();
     this.msg        = AVClient.DeserializeJsonString(estimatedData["msg"].ToString());
 }
Ejemplo n.º 16
0
        public object Apply(object oldValue, string key)
        {
            if (oldValue == null)
            {
                return(new List <object>());
            }
            var oldList = (IList <object>)AVClient.ConvertTo <IList <object> >(oldValue);

            return(oldList.Except(objects, AVFieldOperations.AVObjectComparer).ToList());
        }
Ejemplo n.º 17
0
 static public void Initialize()
 {
     try
     {
         AVClient.Initialize(Consts.APP_ID, Consts.APP_KEY);
     }catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 18
0
        public void AVIMClient_SyncRouter()
        {
            AVClient.Initialize("uay57kigwe0b6f5n0e1d4z4xhydsml3dor24bzwvzr57wdap", "kfgz7jjfsk55r5a8a3y4ttd3je1ko11bkibcikonk32oozww");
            var client = new AVIMClient("Tom");

            AVIMClient.RouterController.GetAsync(CancellationToken.None).ContinueWith(t =>
            {
                Trace.WriteLine(t.Result.server);
            }).Wait();
        }
Ejemplo n.º 19
0
        public Task <Tuple <HttpStatusCode, IDictionary <string, object> > > RunCommandAsync(AVCommand command,
                                                                                             IProgress <AVUploadProgressEventArgs> uploadProgress     = null,
                                                                                             IProgress <AVDownloadProgressEventArgs> downloadProgress = null,
                                                                                             CancellationToken cancellationToken = default(CancellationToken))
        {
            return(httpClient.ExecuteAsync(command, uploadProgress, downloadProgress, cancellationToken).OnSuccess(t => {
                cancellationToken.ThrowIfCancellationRequested();

                var response = t.Result;
                var contentString = response.Item2;
                int responseCode = (int)response.Item1;

                if (AVClient.httpDebugLog)
                {
                    AVClient.LogTracker("Response Code: " + responseCode);
                    AVClient.LogTracker("Response Body: " + contentString);
                }
                if (responseCode >= 500)
                {
                    // Server error, return InternalServerError.
                    throw new AVException(AVException.ErrorCode.InternalServerError, response.Item2);
                }
                else if (contentString != null)
                {
                    IDictionary <string, object> contentJson = null;
                    try {
                        if (contentString.StartsWith("["))
                        {
                            var arrayJson = Json.Parse(contentString);
                            contentJson = new Dictionary <string, object> {
                                { "results", arrayJson }
                            };
                        }
                        else
                        {
                            contentJson = Json.Parse(contentString) as IDictionary <string, object>;
                        }
                    } catch (Exception e) {
                        throw new AVException(AVException.ErrorCode.OtherCause,
                                              "Invalid response from server", e);
                    }
                    if (responseCode < 200 || responseCode > 299)
                    {
                        int code = (int)(contentJson.ContainsKey("code") ? (long)contentJson["code"] : (int)AVException.ErrorCode.OtherCause);
                        string error = contentJson.ContainsKey("error") ?
                                       contentJson["error"] as string :
                                       contentString;
                        throw new AVException((AVException.ErrorCode)code, error);
                    }
                    return new Tuple <HttpStatusCode, IDictionary <string, object> >(response.Item1,
                                                                                     contentJson);
                }
                return new Tuple <HttpStatusCode, IDictionary <string, object> >(response.Item1, null);
            }));
        }
        Task <PushRouterState> QueryAsync(CancellationToken cancellationToken)
        {
            var appRouter  = AVPlugins.Instance.AppRouterController.Get();
            var routerHost = string.Format("https://{0}/v1/route?appId={1}&secure=1", appRouter.RealtimeRouterServer, AVClient.CurrentConfiguration.ApplicationId) ?? appRouter.RealtimeRouterServer ?? string.Format(routerUrl, AVClient.CurrentConfiguration.ApplicationId);

            return(AVClient.RequestAsync(uri: new Uri(routerHost),
                                         method: "GET",
                                         headers: null,
                                         data: null,
                                         contentType: "",
                                         cancellationToken: CancellationToken.None).ContinueWith <PushRouterState>(t =>
            {
                var httpStatus = (int)t.Result.Item1;
                if (httpStatus != 200)
                {
                    throw new AVException(AVException.ErrorCode.ConnectionFailed, "can not reach router.", null);
                }
                try
                {
                    var result = t.Result.Item2;

                    var routerState = Json.Parse(result) as IDictionary <string, object>;
                    if (routerState.Keys.Count == 0)
                    {
                        throw new KeyNotFoundException("Can not get websocket url from server,please check the appId.");
                    }
                    var ttl = long.Parse(routerState["ttl"].ToString());
                    var expire = DateTime.Now.AddSeconds(ttl);
                    routerState["expire"] = expire.UnixTimeStampSeconds();

                    //save to local cache async.
                    AVPlugins.Instance.StorageController.LoadAsync().OnSuccess(storage => storage.Result.AddAsync(routerKey, routerState));
                    var routerStateObj = new PushRouterState()
                    {
                        groupId = routerState["groupId"] as string,
                        server = routerState["server"] as string,
                        secondary = routerState["secondary"] as string,
                        ttl = long.Parse(routerState["ttl"].ToString()),
                        expire = expire.UnixTimeStampSeconds(),
                        source = "online"
                    };

                    return routerStateObj;
                }
                catch (Exception e)
                {
                    if (e is KeyNotFoundException)
                    {
                        throw e;
                    }
                    return null;
                }
            }));
        }
Ejemplo n.º 21
0
        internal Task <FileState> PutFile(FileState state, string uploadUrl, Stream dataStream)
        {
            IList <KeyValuePair <string, string> > makeBlockHeaders = new List <KeyValuePair <string, string> >();

            makeBlockHeaders.Add(new KeyValuePair <string, string>("Content-Type", state.MimeType));

            return(AVClient.RequestAsync(new Uri(uploadUrl), "PUT", makeBlockHeaders, dataStream, state.MimeType, CancellationToken.None).OnSuccess(t =>
            {
                return state;
            }));
        }
Ejemplo n.º 22
0
        public Task SetCurrentConfigAsync(AVConfig config)
        {
            return(taskQueue.Enqueue(toAwait => toAwait.ContinueWith(_ => {
                currentConfig = config;

                var jsonObject = ((IJsonConvertible)config).ToJSON();
                var jsonString = AVClient.SerializeJsonString(jsonObject);

                return storageController.LoadAsync().OnSuccess(t => t.Result.AddAsync(CurrentConfigKey, jsonString));
            }).Unwrap().Unwrap(), CancellationToken.None));
        }
Ejemplo n.º 23
0
        public void initApp()
        {
            Websockets.Net.WebsocketConnection.Link();
            string appId  = ConfigurationManager.AppSettings["appId"];
            string appKey = ConfigurationManager.AppSettings["appKey"];

            avRealtime = new AVRealtime(appId, appKey);
            //avRealtime = new AVRealtime("5ptNj5fF9TplwYYNYo34Ujmi-gzGzoHsz", "oxEMyVyz3XmlI8URg87Xp1l5");

            AVClient.HttpLog(Console.WriteLine);
        }
Ejemplo n.º 24
0
        public Task SetCurrentConfigAsync(AVConfig config)
        {
            return(taskQueue.Enqueue(toAwait => toAwait.ContinueWith(_ => {
                currentConfig = config;

                var jsonObject = ((IJsonConvertible)config).ToJSON();
                var jsonString = AVClient.SerializeJsonString(jsonObject);

                AVClient.ApplicationSettings[CurrentConfigKey] = jsonString;
            }), CancellationToken.None));
        }
Ejemplo n.º 25
0
        public override void ExcuteTask()
        {
            // 后台云初始化
            AVClient.Initialize("Sfwa6nyMhQ6TWK1vnIteSVnf-gzGzoHsz", "dIUA56iTwM3NgfbbiLKPQdBT");

            // 1.找出9大分类
            var cateUrls = GetCategoryUrls("http://www.huamao.com.au/index.php?dispatch=categories.all");

            // 2.获取该分类下的商品列表总页数,然后分页获取数据
            // http://www.huamao.com.au/index.php?dispatch=categories.view&category_id=548&page=2
            Parallel.ForEach(cateUrls, SaveProductsByCateUrl);
        }
Ejemplo n.º 26
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!this.Page.IsPostBack)
     {
         AVClient.Initialize("u2usgtzl5t8w9t2qpf8bbc88rvg85g5tgjtja3jpq0gfoilc", "dspdy8ip356aahviafq216hszwb0gp908vov9b4cck7nrywu");
         this.InitParentCategories();
         if (this.Page.Session[SESSIONKEY] == null)
         {
             this.InitUsers();
         }
     }
 }
        public void AVFile_File_From_String()
        {
            AVClient.Initialize("uay57kigwe0b6f5n0e1d4z4xhydsml3dor24bzwvzr57wdap", "kfgz7jjfsk55r5a8a3y4ttd3je1ko11bkibcikonk32oozww");
            AVClient.EnableDebugLog((obj) =>
            {
                Trace.WriteLine(obj);
            });
            byte[] data = System.Text.Encoding.UTF8.GetBytes("LeanCloud is great good wonderful great good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderfulgreat good wonderful!");
            AVFile file = new AVFile("resume.txt", data);

            file.SaveAsync().Wait();
        }
Ejemplo n.º 28
0
        public static void Main(string[] args)
        {
            AVClient.Initialize("r7WOBCoFgBlpuRoBTIWjb7XI-gzGzoHsz", "PT4FpSvABfO0wKCD4WYA0wdK");

            AVObject football = new AVObject("Sport");

            football["totalTime"] = 90;
            football["name"]      = "Football";
            Task saveTask = football.SaveAsync();

            saveTask.Wait();
        }
        public void AVFile_File_From_String_QCloud()
        {
            AVClient.Initialize("JXyR8vfpeSr8cfaYnob2zYl0-9Nh9j0Va", "Fgq2YlPdnP1KJEoWyF5tk2az");
            AVClient.EnableDebugLog((obj) =>
            {
                Trace.WriteLine(obj);
            });
            byte[] data = System.Text.Encoding.UTF8.GetBytes("LeanCloud is great!");
            AVFile file = new AVFile("resume.txt", data);

            file.SaveAsync().Wait();
        }
        public void Conversation_Join()
        {
            AVClient.Initialize("uay57kigwe0b6f5n0e1d4z4xhydsml3dor24bzwvzr57wdap", "kfgz7jjfsk55r5a8a3y4ttd3je1ko11bkibcikonk32oozww");
            var client = new AVIMClient("John");

            client.UseLeanEngineSignatureFactory();

            client.ConnectAsync().ContinueWith(_ =>
            {
                AVIMConversation consersation = AVIMConversation.CreateWithoutData("575e88521532bc0060995d32", client);
                consersation.JoinAsync().Wait();
            }).Wait();
        }