Exemplo n.º 1
0
        public void Share(String mode, Object payload, LinccerContentCallback callback)
        {
            string uri    = Config.ClientUri + "/action/" + mode;
            var    client = new RestClient
            {
                BaseUrl = Sign(uri)
            };

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

            string sJSON = JsonConvert.SerializeObject(payload, Formatting.None, Utils.DefaultSerializerSettings);

            request.AddHeader(HttpRequestHeader.UserAgent.ToString(), Config.ApplicationName);
            request.AddParameter("text/xml", sJSON, ParameterType.RequestBody);

            client.ExecuteAsync(request, (response, req) =>
            {
                callback(response.Content);
            });
        }
Exemplo n.º 2
0
        public void SubmitEnvironment(LinccerContentCallback callback)
        {
            string uri       = Config.ClientUri + "/environment";
            var    signedUri = Sign(uri);
            var    client    = new RestClient
            {
                BaseUrl = Sign(uri)
            };

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

            request.AddHeader(HttpRequestHeader.UserAgent.ToString(), Config.ApplicationName);
            request.AddParameter("text/xml", Environment.ToString(), ParameterType.RequestBody);

            Debug.WriteLine(Sign(signedUri));

            client.ExecuteAsync(request, (response, req) =>
            {
                callback(response.Content);
            });
        }
Exemplo n.º 3
0
        public void UpdateLocation(GeoCoordinate location, LinccerContentCallback callback)
        {
            // set geo position (must be changed to work on other locations than Molkenmarkt 2 in Berlin, Germany)
            //41.38690, 2.16532
            //41.386843, 2.165176
            //this._linccer.Gps = new LocationInfo { Latitude = location.Latitude, Longitude = location.Longitude, Accuracy = 1000 };
            //41.383164, 2.131466

            this._linccer.Gps = new LocationInfo { Latitude = 41.386843, Longitude = 2.165176, Accuracy = 1000 };
            this._linccer.SubmitEnvironment(callback);
        }
Exemplo n.º 4
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="content"></param>
 /// <param name="mode">one-to-many / one-to-one</param>
 /// <param name="callback"></param>
 public void SendTextToOne(string content, LinccerContentCallback callback)
 {
     SendText(content, SendMode.OneToOne, callback);
 }
Exemplo n.º 5
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="data"></param>
 /// <param name="mode">one-to-many / one-to-one</param>
 /// <param name="callback"></param>
 public void SendDataToOne(byte[] data, LinccerContentCallback callback)
 {
     SendData(data, SendMode.OneToOne, callback);
 }
Exemplo n.º 6
0
 public void ReceiveFromOne( LinccerContentCallback contentCallback, FileCacheGetCallback fileCallback)
 {
     Receive(SendMode.OneToOne, contentCallback, fileCallback);
 }
Exemplo n.º 7
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="content"></param>
        /// <param name="mode">one-to-many / one-to-one</param>
        /// <param name="callback"></param>
        private void SendText(string content, SendMode mode, LinccerContentCallback callback)
        {
            // create a plain message
            Hoc hoc = new Hoc();
            hoc.DataList.Add(
                new HocData { Content = content, Type = "text/plain" }
            );

            // share it 1:1, in the Hoccer mobile App, you need to perform a drag in
            // gesture to receive the message  (one-to-many is throw/catch)
            var stringMode = SendModeString.ConvertSendModeToString(mode);
            this._linccer.Share(stringMode, hoc, callback);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="data"></param>
        /// <param name="mode">one-to-many / one-to-one</param>
        /// <param name="callback"></param>
        private void SendData(byte[] data, SendMode mode, LinccerContentCallback callback)
        {
            // inialize filecache for temporary up- and downloading large files
            var cache = new FileCache();
            cache.Config = this._config;

            cache.Store(data, TIMEOUT, (uri) =>
            {
                Hoc hoc = new Hoc();
                hoc.DataList.Add(
                    new HocData { Uri = uri }
                );

                var stringMode = SendModeString.ConvertSendModeToString(mode);
                // share it 1:1, in the Hoccer mobile App, you need to perform a drag in
                // gesture to receive the message  (one-to-many is throw/catch)
                this._linccer.Share(stringMode, hoc, callback);
            });
        }
Exemplo n.º 9
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);
                }
            });
        }