예제 #1
0
        public void Fetch(string uri, FileCacheGetCallback callback)
        {
            var client = new RestClient
            {
                BaseUrl = uri
            };

            var request = new RestRequest
            {
                Method = Method.GET
            };

            request.AddHeader(HttpRequestHeader.UserAgent.ToString(), Config.ApplicationName);

            client.ExecuteAsync(request, (response, req) =>
            {
                callback(response.RawBytes);
            });
        }
예제 #2
0
 public void ReceiveFromOne( LinccerContentCallback contentCallback, FileCacheGetCallback fileCallback)
 {
     Receive(SendMode.OneToOne, contentCallback, fileCallback);
 }
예제 #3
0
        private void Receive(SendMode mode, LinccerContentCallback contentCallback, FileCacheGetCallback fileCallback)
        {
            var stringMode = SendModeString.ConvertSendModeToString(mode);
            // receive 1:1, in the Hoccer mobile App, you need to perform a drag out
            // gesture to send something to this client (one-to-many is throw/catch)
            this._linccer.Receive<Hoc>(stringMode, (hoc) =>
            {
                if (hoc == null)
                {
                    contentCallback(null);
                }
                else
                {
                    if(hoc.DataList.Any(x => x.Type == "text/plain"))
                    {
                        contentCallback(String.Join(",", hoc.DataList.Where(x => x.Type == "text/plain").Select(x => x.Content)));
                        return;
                    }

                    var data = hoc.DataList.FirstOrDefault(x => x.Uri != string.Empty);

                    //// inialize filecache for temporary up- and downloading large files
                    var cache = new FileCache();
                    cache.Config = this._config;
                    cache.Fetch(data.Uri, fileCallback);
                }
            });
        }