#1 2015-04-21 10:22:38

Thomas-Acia
Member
From: Metz (France)
Registered: 2015-04-16
Posts: 79

"ExportServerNamedPipe" Alternative

Hi,

I would like to create a little server with the "Sum" fonction, as we can see in the Sample 06 but I would like to create a communication between a server on linux and a client on W7. So I'm searching an alternative to replace the function ExportServerNamedPipe.

Can I use a TSQLRestServer ?


Delphi 2010 - Delphi XE5 (x64 Apps) - CodeTyphon - Typhon IDE v 5.7 - FPC 3.1.1 - mORMot 1.18
Windows 7 - VirtualBox : Linux Debian 8.5 Jessie 32 bits

Offline

#2 2015-04-21 11:17:38

AOG
Member
Registered: 2014-02-24
Posts: 490

Re: "ExportServerNamedPipe" Alternative

Have a look at Sample 26 !
You will find all you need !!

Offline

#3 2015-04-21 11:51:06

Thomas-Acia
Member
From: Metz (France)
Registered: 2015-04-16
Posts: 79

Re: "ExportServerNamedPipe" Alternative

AOG wrote:

Have a look at Sample 26 !
You will find all you need !!

Thank's !!!!! big_smile big_smile


Delphi 2010 - Delphi XE5 (x64 Apps) - CodeTyphon - Typhon IDE v 5.7 - FPC 3.1.1 - mORMot 1.18
Windows 7 - VirtualBox : Linux Debian 8.5 Jessie 32 bits

Offline

#4 2015-04-21 12:05:39

Thomas-Acia
Member
From: Metz (France)
Registered: 2015-04-16
Posts: 79

Re: "ExportServerNamedPipe" Alternative

"  FileFromString(Ctxt.Call.InBody,FileName); "

RESTServerClass.pas(68,32) Fatal: Syntax error, ")" expected but "identifier INBODY" found

roll


Delphi 2010 - Delphi XE5 (x64 Apps) - CodeTyphon - Typhon IDE v 5.7 - FPC 3.1.1 - mORMot 1.18
Windows 7 - VirtualBox : Linux Debian 8.5 Jessie 32 bits

Offline

#5 2015-04-21 12:28:17

AOG
Member
Registered: 2014-02-24
Posts: 490

Re: "ExportServerNamedPipe" Alternative

Add this:

unit RESTServerClass;

interface

{$I Synopse.inc} // <---- add this !!

uses
  SysUtils,
  Classes,

Offline

#6 2015-04-21 12:33:14

Thomas-Acia
Member
From: Metz (France)
Registered: 2015-04-16
Posts: 79

Re: "ExportServerNamedPipe" Alternative

AOG wrote:

Add this:

unit RESTServerClass;

interface

{$I Synopse.inc} // <---- add this !!

uses
  SysUtils,
  Classes,

Thank you. I'm sorry for all my questions but I'm new in the mORMot's world !


Delphi 2010 - Delphi XE5 (x64 Apps) - CodeTyphon - Typhon IDE v 5.7 - FPC 3.1.1 - mORMot 1.18
Windows 7 - VirtualBox : Linux Debian 8.5 Jessie 32 bits

Offline

#7 2015-04-21 12:42:10

AOG
Member
Registered: 2014-02-24
Posts: 490

Re: "ExportServerNamedPipe" Alternative

No problem !
Not all samples are out-of-the-box prepared for FPC / Lazarus / CodeTyphon.
But I am working on this.
(as an extra: preparingall command line samples to compile with IntelliJ)

But in general: you have to use {$MODE Delphi} for mORMot to work with FPC.
1) by changing the compiler settings
2) by adding {$MODE Delphi} to the source
3) by including Synopse.inc

Offline

#8 2015-04-21 12:50:17

Thomas-Acia
Member
From: Metz (France)
Registered: 2015-04-16
Posts: 79

Re: "ExportServerNamedPipe" Alternative

Ok. It's a very good project for me and all the team is working very well to fix the mistakes.

Thank you for your councils !


Delphi 2010 - Delphi XE5 (x64 Apps) - CodeTyphon - Typhon IDE v 5.7 - FPC 3.1.1 - mORMot 1.18
Windows 7 - VirtualBox : Linux Debian 8.5 Jessie 32 bits

Offline

#9 2015-04-22 08:03:35

Thomas-Acia
Member
From: Metz (France)
Registered: 2015-04-16
Posts: 79

Re: "ExportServerNamedPipe" Alternative

I had the Sum function to the server and I create a button to do the calcul to the client (Sample 26). There are my codes :

Server :

 type
  // TSQLRestServerFullMemory kind of server is light and enough for our purpose
  TServiceServer = class(TSQLRestServerFullMemory)
  published
    procedure Sum(Ctxt: TSQLRestServerURIContext);
  end;

  { TServiceServer }

procedure TServiceServer.Sum(Ctxt: TSQLRestServerURIContext);
var a,b: double;
begin

  if UrlDecodeNeedParameters(Ctxt.Parameters,'A,B') then begin
    while Ctxt.Parameters<>nil do begin
      UrlDecodeDouble(Ctxt.Parameters,'Nombre 1 :',a);
      UrlDecodeDouble(Ctxt.Parameters,'Nombre 2 :',b,@Ctxt.Parameters);
    end;
    Ctxt.Results([a+b]);
  end else
    Ctxt.Error('Missing Parameter');
end;

Client :

procedure TMainForm.btn_calcClick(Sender: TObject);
//ajout de la somme
  var a,b: double;
    err: integer;
    Note: TSQLNoteFile;

begin
  val(edt_a.Text,a,err);
  if err<>0 then begin
    edt_a.SetFocus;
    exit;
  end;
  val(edt_b.Text,b,err);
  if err<>0 then begin
    edt_b.SetFocus;
    exit;
  end;

  if fClient=nil then
    exit;
    Note := TSQLNoteFile.Create;
  try
   lbl_res.Caption := UTF8ToString(fClient.CallBackGetResult('Sum',['A',a,'B',b]));
  finally
    Note.Free;
  end;
end;

But the result is : 400 Bad Request. I used CommView to check if the client's connection to the server is working, it is. I think my problem is in the code but I don't see it ...

Last edited by Thomas-Acia (2015-04-22 08:03:58)


Delphi 2010 - Delphi XE5 (x64 Apps) - CodeTyphon - Typhon IDE v 5.7 - FPC 3.1.1 - mORMot 1.18
Windows 7 - VirtualBox : Linux Debian 8.5 Jessie 32 bits

Offline

#10 2015-04-22 11:07:41

AOG
Member
Registered: 2014-02-24
Posts: 490

Re: "ExportServerNamedPipe" Alternative

In your client code, you send variables "A" and "B" to server method "Sum":

fClient.CallBackGetResult('Sum',['A',a,'B',b])

In your server code, you decode "Nombre 1" and "Nombre 2" in method "Sum":

UrlDecodeDouble(Ctxt.Parameters,'Nombre 1 :',a);
UrlDecodeDouble(Ctxt.Parameters,'Nombre 2 :',b,@Ctxt.Parameters);

Try this in your server:

UrlDecodeDouble(Ctxt.Parameters,'A=',a);
UrlDecodeDouble(Ctxt.Parameters,'B=',b,@Ctxt.Parameters);

Offline

#11 2015-04-22 12:01:15

Thomas-Acia
Member
From: Metz (France)
Registered: 2015-04-16
Posts: 79

Re: "ExportServerNamedPipe" Alternative

AOG wrote:

In your client code, you send variables "A" and "B" to server method "Sum":

fClient.CallBackGetResult('Sum',['A',a,'B',b])

In your server code, you decode "Nombre 1" and "Nombre 2" in method "Sum":

UrlDecodeDouble(Ctxt.Parameters,'Nombre 1 :',a);
UrlDecodeDouble(Ctxt.Parameters,'Nombre 2 :',b,@Ctxt.Parameters);

Try this in your server:

UrlDecodeDouble(Ctxt.Parameters,'A=',a);
UrlDecodeDouble(Ctxt.Parameters,'B=',b,@Ctxt.Parameters);

It was a stupid error. My method "Sum" was declared in the class "TServiceServer" and when I called the function I used the class "TSQLNoteFile" neutral


Delphi 2010 - Delphi XE5 (x64 Apps) - CodeTyphon - Typhon IDE v 5.7 - FPC 3.1.1 - mORMot 1.18
Windows 7 - VirtualBox : Linux Debian 8.5 Jessie 32 bits

Offline

Board footer

Powered by FluxBB