Exemple #1
0
        private void StartGeofenceMonitoring(ICallback callback, String geofenceName, AsyncCallback <object> responder)
        {
            var innerResponder = new AsyncCallback <GeoFence>(
                r =>
            {
                try
                {
                    AddFenceMonitoring(callback, new GeoFence[] { r });
                }
                catch (System.Exception e)
                {
                    if (responder != null)
                    {
                        responder.ErrorHandler(new BackendlessFault(e));
                    }
                }
            },
                f =>
            {
                if (responder != null)
                {
                    responder.ErrorHandler(f);
                }
            });

            Object[] args = new Object[] { geofenceName };
            Invoker.InvokeAsync(GEO_MANAGER_SERVER_ALIAS, "getFence", args, innerResponder);
        }
Exemple #2
0
        public void SendCommand(String type, Object data, AsyncCallback <Object> callback)
        {
            Log.log(Backendless.BACKENDLESSLOG, String.Format("Send command with type {0}", type));
            CommandRequest rtMethodRequest = CreateCommandRequest(new RTCallback <Object>(callback, result =>
            {
                Log.log(Backendless.BACKENDLESSLOG, "command sent");

                if (callback != null)
                {
                    callback.ResponseHandler(null);
                }
            }, fault =>
            {
                Log.log(Backendless.BACKENDLESSLOG, String.Format("error when sending command {0}", fault));
                if (callback != null)
                {
                    callback.ErrorHandler(fault);
                }
            }));

            rtMethodRequest.SetData(data).SetType(type);

            if (IsConnected())
            {
                rtClient.Invoke(rtMethodRequest);
            }
            else
            {
                commandsToSend.Enqueue(rtMethodRequest);
            }
        }
        private IList <T> LoadRelationsImpl <T>(string parentType, string objectId, LoadRelationsQueryBuilder <T> queryBuilder, AsyncCallback <IList <T> > responder)
        {
            if (string.IsNullOrEmpty(objectId))
            {
                if (responder != null)
                {
                    responder.ErrorHandler(new BackendlessFault(ExceptionMessage.NULL_ID));
                }
                else
                {
                    throw new ArgumentNullException(ExceptionMessage.NULL_ID);
                }
            }

            if (queryBuilder == null)
            {
                String error = "Cannot execute load relations request. The queryBuilder argument must not be null";

                if (responder != null)
                {
                    responder.ErrorHandler(new BackendlessFault(error));
                }
                else
                {
                    throw new ArgumentNullException(error);
                }
            }

            BackendlessDataQuery dataQuery = queryBuilder.Build();
            String relationName            = dataQuery.QueryOptions.Related[0];
            int    pageSize = dataQuery.PageSize;
            int    offset   = dataQuery.Offset;

            AddWeborbPropertyMapping <T>();
            Object[] args = new Object[] { parentType, objectId, relationName, pageSize, offset };

            if (responder == null)
            {
                return((IList <T>)Invoker.InvokeSync <IList <T> >(PERSISTENCE_MANAGER_SERVER_ALIAS, "loadRelations", args, true));
            }
            else
            {
                Invoker.InvokeAsync <IList <T> >(PERSISTENCE_MANAGER_SERVER_ALIAS, "loadRelations", args, true, responder);
                return(null);
            }
        }
Exemple #4
0
        public void Get <T>(String key, AsyncCallback <T> callback)
        {
            AsyncCallback <byte[]> interimCallback = new AsyncCallback <byte[]>(
                result =>
            {
                callback.ResponseHandler((T)deserialize <T>(result));
            },
                fault =>
            {
                callback.ErrorHandler(fault);
            });

            Invoker.InvokeAsync(CACHE_SERVER_ALIAS, "getBytes", new Object[] { key }, interimCallback);
        }
Exemple #5
0
        public void Listing(string path, string pattern, bool recursive, int pagesize, int offset,
                            AsyncCallback <IList <FileInfo> > responder)
        {
            AsyncCallback <IList <FileInfo> > listingCallback = new AsyncCallback <IList <FileInfo> >(
                files =>
            {
                responder?.ResponseHandler(files);
            },
                error =>
            {
                responder?.ErrorHandler(error);
            }
                );

            object[] args = { path, pattern, recursive, pagesize, offset };
            Invoker.InvokeAsync(FILE_MANAGER_SERVER_ALIAS, "listing", args, listingCallback);
        }
Exemple #6
0
        public void LoadMetadata(GeoPoint point, AsyncCallback <GeoPoint> callback)
        {
            AsyncCallback <Dictionary <string, object> > loadMetaCallback = new AsyncCallback <Dictionary <string, object> >(
                result =>
            {
                point.Metadata = result;

                callback?.ResponseHandler(point);
            },
                fault =>
            {
                callback?.ErrorHandler(fault);
            });

            try
            {
                object[] methodArgs = null;

                if (point is GeoCluster cluster)
                {
                    methodArgs = new object[] { cluster.ObjectId, cluster.GeoQuery }
                }
                ;
                else
                {
                    methodArgs = new object[] { point.ObjectId, null }
                };

                Invoker.InvokeAsync(GEO_MANAGER_SERVER_ALIAS, "loadMetadata", methodArgs, loadMetaCallback);
            }
            catch (System.Exception ex)
            {
                if (callback != null)
                {
                    callback.ErrorHandler.Invoke(new BackendlessFault(ex));
                }
                else
                {
                    throw;
                }
            }
        }
Exemple #7
0
    private void StartGeofenceMonitoring( ICallback callback, String geofenceName, AsyncCallback<object> responder )
    {
      var innerResponder = new AsyncCallback<GeoFence>(
        r =>
        {
          try
          {
            AddFenceMonitoring( callback, new GeoFence[] { r } );
          }
          catch( System.Exception e )
          {
            if( responder != null )
              responder.ErrorHandler( new BackendlessFault( e ) );
          }
        },
        f =>
        {
          if( responder != null )
            responder.ErrorHandler( f );
        } );

      Object[] args = new Object[] { Backendless.AppId, Backendless.VersionNum, geofenceName };
      Invoker.InvokeAsync( GEO_MANAGER_SERVER_ALIAS, "getFence", args, innerResponder );
    }