FANDOM


firebase_async_HTTP_module Editar

Modulo de la extensión

Sintaxis:

firebase_async_HTTP_module();

Retorno: N/A

Descripción

Ésta función se encarga administrar todas las respuestas enviadas desde firebase, debe ser colocado dentro del evento HTTP. Su uso es opcional pudiendo el usuario programar ésta funcionalidad según sus requerimientos.

Código del script:

Se muestra a continuación el código del script en la versión 1.0:

///firebase_async_HTTP_module()

var suscribeID,suscribeResult,suscribeDs,reqName,key,value;

suscribeID=ds_map_find_value(async_load, "id")

if (suscribeID<>-1 and ds_map_exists(global.FIREBASE_request_data,suscribeID)){

if ds_map_find_value(async_load, "status") == 0{
var suscribeResult=ds_map_find_value(async_load, "result");

suscribeDs=json_decode(suscribeResult)

if (suscribeDs==-1){suscribeDs=ds_map_create()suscribeDs[? '0']=suscribeResult}

reqName=''

key=ds_map_find_first(global.FIREBASE_request_name)

repeat(ds_map_size(global.FIREBASE_request_name)){
value=global.FIREBASE_request_name[? key]
if (value==suscribeID){
reqName=key
}else{
key=ds_map_find_next(global.FIREBASE_request_name,key)
}
}

moduleDs=ds_map_create()
moduleDs[? 'ID']=suscribeID
moduleDs[? 'Name']=reqName

responseDs=ds_map_create()
ds_map_add_map(responseDs,'module',moduleDs)
ds_map_add_map(responseDs,'response',suscribeDs)

suscribeResult=json_encode(responseDs)
ds_map_destroy(moduleDs)
ds_map_destroy(suscribeDs)
ds_map_destroy(responseDs)

ds_map_replace(global.FIREBASE_request_data,suscribeID,suscribeResult)
eventAction(suscribeID,suscribeResult)


}else
{
var suscribeResult='Null';

ds_map_replace(global.FIREBASE_request_data,suscribeID,suscribeResult)

}

}

Editar