Skip to content

Instantly share code, notes, and snippets.

@FrancisVarga
Created May 31, 2010 16:27
Show Gist options
  • Save FrancisVarga/419988 to your computer and use it in GitHub Desktop.
Save FrancisVarga/419988 to your computer and use it in GitHub Desktop.
btn_submit.addEventListener("click",
FunctionUtil.newDelegate(
this,
function(event)
{
try{
tracer.text='';
firelog("submit");
application.gateway.debugUrl=ti_gateway_debug.text;
application.gateway.liveUrl=ti_gateway_live.text
application.gateway.liveKey=ti_gateway_key.text
application.gateway.debugMode = (cb_debugMode.selected==true);
var service=new JSONRPCService(this.application.client);
var rpcBaseParamsText = ti_rpcBaseParams.text;
try {
var rpcBaseParams = JSON.decode(rpcBaseParamsText);
}catch(ex){
throw new Error("Error while json parsing rpcBaseParams: "+ex+" rpcParamsText: "+rpcBaseParamsText);
}
var rpcText = ti_rpc.text;
try{
var rpcData = JSON.decode(rpcText);
}catch(ex){
throw new Error("Error while json parsing rpc: "+ex);
}
var rpcMethod;
var rpcParams;
if (rpcData is Object)
{
rpcMethod = rpcData.method;
rpcParams = rpcData.params;
}
xtrace('--------- invoke -----------');
xtrace('rpcMethod: '+rpcMethod);
xtrace('rpcParams: '+rpcParams);
xtrace('rpcBaseParams: '+rpcBaseParams);
firelog("invoke",{
debugMode: application.gateway.debugMode,
rpcMethod:rpcMethod,
rpcParams:rpcParams,
rpcBaseParams:rpcBaseParams
});
var rpc=service._invoke2(rpcMethod,rpcParams,rpcBaseParams);
xtrace("rpc: "+rpc);
rpc.scope=this;
var me=this;
rpc.on={
error:function(event)
{
xtrace('onError: '+event);
firelog('onError: '+event);
if (event.error)
{
xtrace("\n\nevent.error: "+event.error);
firelog('onError: event.error='+event.error+" ",event.error);
if (event.error.data)
{
xtrace("\n\nevent.error.data: "+event.error.data);
for (var key in event.error.data)
{
xtrace("\n ."+key+" = "+event.error.data[key]);
}
}
}
},
result:function(event){
xtrace("onResult: "+event);
xtrace("event.result: "+event.result);
xtrace("event.result (json): "+JSON.encode(event.result));
firelog('onResult: event.result='+event.result+" ",event.result);
}
}
}
catch(error)
{
xtrace("catched error: "+error);
xtrace("\n\nCatched error while trying to invoke service!");
}
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment