Jump to content

UniGUIServerModuleHTTPCommand


herculanojs

Recommended Posts

Something strange, what am I doing wrong?
 
I'm trying to connect a fmx application with unigui through http, and the response I get from the server has nothing to do with what was sent.
 
In server:
 
type
  TUniServerModule = class(TUniGUIServerModule)
    procedure UniGUIServerModuleHTTPCommand(ARequestInfo: TIdHTTPRequestInfo;
      AResponseInfo: TIdHTTPResponseInfo; var Handled: Boolean);
 
  private
    { Private declarations }
 
  protected
    procedure FirstInit; override;
  public
    { Public declarations }
     procedure AfterConstruction; override;
  end;
 
procedure TUniServerModule.UniGUIServerModuleHTTPCommand(
  ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo;
  var Handled: Boolean);
begin
     AResponseInfo.ResponseText := 'ok request in server';
end;
 
-------------------------

In Client fmx:

 

procedure TForm5.Button2Click(Sender: TObject);
var buffer:tstringlist;
    Parametros:string;
    Response: TStringStream;
begin
     Try
        buffer := TStringList.create;
        buffer.Clear;
        buffer.Add('teste');
        Response := TStringStream.Create('');
        try
            //Parametros := '?LeituraBina&'+cEvento+'&'+cCanal+'&'+cNumero+'&'+cdata;
 
            IdHTTP1.Request.CustomHeaders.Clear;
            IdHTTP1.Request.Clear;
            IdHTTP1.Request.Accept := 'text/xml';
            IdHTTP1.Request.ContentType := 'text/xml';
            IdHTTP1.Request.ContentEncoding := 'utf-8';
 
            Memo1.Lines.Clear;
            IdHTTP1.Post(Edit2.Text,buffer,Response);
            memo1.Lines.Add(Response.dataString);
 
        except
 
        end;
     Finally
        buffer.free;
        Response.Free;
     End;
 
end;
 
Received:
 
<!DOCTYPE html public>
<html lang="">
<head>
<title>New Application</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="content-type" content="charset=utf-8">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="-1">
<link REL="SHORTCUT ICON" HREF="/cache/project1_exe/eQ7XxdhMb4101127EB7/favicon.ico">
 
<link rel=stylesheet href="/uni-1.0.0.1412/css/uni-ext.css" />
<link rel=stylesheet href="/ext-4.2.5.1763/resources/css/ext-all.css" />
<script src="/ext-4.2.5.1763/ext-all.js"></script>
<script src="/uni-1.0.0.1412/ext-unicommon-min.js"></script>
<script src="/uni-1.0.0.1412/ext-sync-min.js"></script>
<script src="/ext-4.2.5.1763/locale/ext-lang-.js"></script>
<script type="text/javascript">
 
Ext.Loader.setConfig({disableCaching:false,enabled:true,paths:{"Ext.uni":"/uni-1.0.0.1412/"}});Ext.Loader.setConfig({disableCaching:true})
 
</script>
 
<script src="/uni-1.0.0.1412/AlwaysOnTop.js"></script>
<script src="/uni-1.0.0.1412/jQuery/jquery-1.11.2.min.js"></script>
<script src="/uni-1.0.0.1412/ClearButton/ClearButton.js"></script>
<link rel=stylesheet href="/uni-1.0.0.1412/ClearButton/ClearButton.css" />
<script src="/uni-1.0.0.1412/jQuery/MaskedInput/jquery.inputmask.min.js"></script>
<script src="/uni-1.0.0.1412/jQuery/autoNumeric/autoNumeric-1.9.35.js"></script>
<link rel=stylesheet href="/uni-1.0.0.1412/css/uni-xtheme-common.css" />
<link rel=stylesheet href="/uni-1.0.0.1412/css/uni-xtheme.css" />
<script src="/uni-1.0.0.1412/ext-unigui-min.js"></script>
 
</head>
<script>
uniVars._extVer="4.2.5";_S_ID="_S_ID=eQ7XxdhMb4101127EB7";uniSyncObj.errShow=true;uniSyncObj.errText="Connection Error";uniSyncObj.errRetryText="Retrying...";uniSyncObj.errTextColor="#0055AA";uniSyncObj.errAfterRetry=1;uniSyncObj.errLogTry=0x7ef4f2fa;uniSyncObj.licOwn="Y2BtXnBnXGlqZW47YmhcZGcpXmpo";uniSyncObj.srcArr="XjOhUtVo";
Ext.application({name:"uniApplication",controllers: ["Ext.ux.util.AlwaysOnTop"],launch: function(){setTimeout(function(){Ext.get("loading").remove();Ext.get("loading-mask").fadeOut({remove:true});},250);Ext.BLANK_IMAGE_URL="/ext-4.2.5.1763/resources/themes/images/default/tree/s.gif";
Ext.BLANK_IMAGE_SRC="<img src="+Ext.BLANK_IMAGE_URL+">";
TextMetrics=new Ext.util.TextMetrics(Ext.getBody());
var _ajxerr=false;_ifrm_("FRM_eQ7XxdhMb4101127EB7");_showAjaxErr=true;_ajxflerr="Communication Error";Download=Ext.DomHelper.append(document.body,{tag:"iframe",cls:"x-hidden"});try{ O0=new Ext.window.Window({id:"O0_id",retfalse:{},onEsc:Ext.emptyFn,layout:"fit",title:"MainForm",maximizable:true,minimizable:true,resizable:true,icon:"/cache/project1_exe/eQ7XxdhMb4101127EB7/favicon.ico",uniFMask:{beforeclose:true},width:625,height:444});O0.nm="O0";_cdo_("MainForm");MainForm.ajxS=AjaxSuccess;MainForm.ajxF=AjaxFailure;O0.rootObj=true;MainForm.appRoot="/";_cdo_(null,O0,"window",MainForm); O8=new Ext.form.Panel({id:"O8_id",border:false,tabItems:new Ext.util.MixedCollection(),layout:"absolute"});O8.nm="O8";_cdo_(null,O8,"form",MainForm);O0.add(O8); O10= (function(P0){return Ext.Ajax.request({url:"/HandleEvent",params:"Ajax=1&IsEvent=1&Obj=O0&Evt=beforeclose&this="+P0.nm+""+_gv_(O8),success:AjaxSuccess,failure:AjaxFailure,obj:O0,e:"beforeclose"});});O10.nm="O10";O0.on("beforeclose",O10); O11= (function(P0){_saf_(P0);return Ext.Ajax.request({url:"/HandleEvent",params:"Ajax=1&IsEvent=1&Obj=O0&Evt=activate&this="+P0.nm+""+_gv_(O8),success:AjaxSuccess,failure:AjaxFailure,obj:O0,e:"activate"});});O11.nm="O11";O0.on("activate",O11); O12= (function(P0){return Ext.Ajax.request({url:"/HandleEvent",params:"Ajax=1&IsEvent=1&Obj=O0&Evt=deactivate&this="+P0.nm+""+_gv_(O8),success:AjaxSuccess,failure:AjaxFailure,obj:O0,e:"deactivate"});});O12.nm="O12";O0.on("deactivate",O12);uniVars._mFrm_=O8;O0.on("deactivate",function(f){_sdf_(f)});ajaxRequest(O0,"cinfo",{ci:_gci_()}); O13=new Ext.container.Viewport({id:"O13_id",layout:"border",autoScroll:true,style:"background:#004080;"});O13.nm="O13";_cdo_(null,O13,"viewport",MainForm);uniVars._vport=O13;Ext.util.Format.decimalSeparator=",";Ext.util.Format.thousandSeparator=".";_cwk_();uniVars.gNavigate={e:true,t:true,c:true,gn:{s:0},gp:{s:0},gs:{s:0},gc:{s:0}};_dko_({BS:true,ESC:true}); O1B= (function(P0,P1,P2){return Ext.Ajax.request({url:"/HandleEvent",params:"Ajax=1&IsEvent=1&Obj=O0&Evt=resize&this="+P0.nm+"&w="+P1+"&h="+P2+""+_gv_(O8),success:AjaxSuccess,failure:AjaxFailure,obj:O0,e:"resize"});});O1B.nm="O1B";O0.on("resize",O1B); O1C= (function(P0,P1,P2){return Ext.Ajax.request({url:"/HandleEvent",params:"Ajax=1&IsEvent=1&Obj=O0&Evt=move&this="+P0.nm+"&x="+P1+"&y="+P2+""+_gv_(O8),success:AjaxSuccess,failure:AjaxFailure,obj:O0,e:"move"});});O1C.nm="O1C";O0.on("move",O1C); O1D= (function(P0){return Ext.Ajax.request({url:"/HandleEvent",params:"Ajax=1&IsEvent=1&Obj=O0&Evt=maximize&this="+P0.nm+""+_gv_(O8),success:AjaxSuccess,failure:AjaxFailure,obj:O0,e:"maximize"});});O1D.nm="O1D";O0.on("maximize",O1D); O1E= (function(P0){return Ext.Ajax.request({url:"/HandleEvent",params:"Ajax=1&IsEvent=1&Obj=O0&Evt=minimize&this="+P0.nm+""+_gv_(O8),success:AjaxSuccess,failure:AjaxFailure,obj:O0,e:"minimize"});});O1E.nm="O1E";O0.on("minimize",O1E); O1F= (function(P0){return Ext.Ajax.request({url:"/HandleEvent",params:"Ajax=1&IsEvent=1&Obj=O0&Evt=restore&this="+P0.nm+""+_gv_(O8),success:AjaxSuccess,failure:AjaxFailure,obj:O0,e:"restore"});});O1F.nm="O1F";O0.on("restore",O1F); O20= (function(P0,P1,P2){return Ext.Ajax.request({url:"/HandleEvent",params:"Ajax=1&IsEvent=1&Obj=O13&Evt=resize&this="+P0.nm+"&w="+P1+"&h="+P2+""+_gv_(O8),success:AjaxSuccess,failure:AjaxFailure,obj:O13,e:"resize"});});O20.nm="O20";O13.on("resize",O20);showBrowserWarning("Your browser is not supported.\x3Cbr /\x3EYou may experience compatibility issues.");O0.show("");O0.retfalse.beforeclose=1;_axy_(O0);O0.uniMask={ldMask:false,maskWaitData:false,maskUseMsg:true};O0.uniMask.targetObj=null;}catch(e){alert(e.message)}}});
window.onunload=function(){_cunld_()}
</script>
<body>
<div id="loading-mask"></div><div id="loading"><div class="loading-indicator">Loading...</div></div>
<div id=body></div><noscript>This web application requires JavaScript enabled</noscript></body>
</html>
 

 

Link to comment
Share on other sites


procedure TUniServerModule.UniGUIServerModuleHTTPCommand(

  ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo;

  var Handled: Boolean);

begin


     Handled := true; ???

     AResponseInfo.ResponseText := 'recebido no servidor';

end; 

 

 

client:

 


 Memo1.Lines.Clear;

 IdHTTP1.Post(Edit2.Text,buffer,Response);

 memo1.Lines.Add(Response.dataString);

 

now I get nothing more

 

Link to comment
Share on other sites

Next, I have the idea of ​​using the unigui application, running inside a webbrowser in a firemonkey application.
 
So far so good.
However given the problematic in communication with the hardware of the web application (unigui) with the equipment (mobile), I intend to make the hole of information between them through http of the server.
 
The final sen- sor is printing the invoice on a bluetooth printer. That is, in the application running on unigui, the operator will complete the sales process, and in the end the application should send a command to the external application firemonkey, with the file, instructions for printing the voucher, communication with other hardware.
 
What do you think ?
And any ideas on how to implement this?
 
Firstly, I'm thinking of starting the browser session by passing parameters to identify the external application and to know how to act in unigui.
 
The external application would have an idhttp for the unigui application to communicate with it.
 
Would it be possible ?
 
I noticed that on the unigui server when adjusting Handled: = true;
session is not started on the server.
 
procedure TUniServerModule.UniGUIServerModuleHTTPCommand (
   ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo;
   var Handled: Boolean);
begin
      Handled: = true;
      AResponseInfo.ContentText: = 'received on server';
end;

 

post-1670-0-95574600-1517268763_thumb.png

Link to comment
Share on other sites

I think with something in this line, it would be possible to solve problems of interaction with the hardware, in cases to which we need to interact with the equipment. Print something directly, read digital, among other things.

 

I'll be deepening the tests, and everything going well, maybe put my application to run inside the webbrowser itself for situations that need to interact with the pc

Link to comment
Share on other sites

  • 5 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...