Jump to content

Rav

Members
  • Posts

    89
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by Rav

  1. Hi,

     

    But what if you will use "UniDBGrid" with pages ?!

     

    Best regards.

    The data I am showing in the ListViews are fluent, change rapidly and are not located in the database, only in server's RAM. Do you think that UniDBGrid is the best component for showing such data?

  2. Each unigui session , ( main module or your unigui main form ), can have her custom tcp client, and you can comunicate it like a vcl application, with your custom server.

     

    If you want to communicate with a  TCP server  from  a Unigui Application , just add the  Indy component  IdTcpClient to Unigui Form.

    Yes I tested idTCPClient, it works fine, thank you!

    Then I decided to try idTCPServer on the client side and tested the code:

    procedure TMainForm.UniFormCreate(Sender: TObject);
    begin
      idServer := TIdTCPServer.Create;
      idServer.OnExecute := idServerExecute;
      idServer.DefaultPort := 12345;
      idServer.Active := True;
      UniLabel2.Caption := 'Test';//Works fine
    end;
    
    procedure TMainForm.idServerExecute(AContext: TIdContext);
    var
      i: integer;
    begin
      with AContext.Connection.Socket do
        try
          i := ReadLongint;
          UniLabel2.Caption := inttostr(i);//Exception
        except
        end;
    end;
    

    This code gives an exception "Attempt to access nil session reference" while referencing UniLabel2. Why is that?

    I guess this relates to the fact that idServerExecute is executed by Indy in a thread, but why "session is nil"?

    And another question, VCL components are not thread safe, is the situation the same with UniGui controls?

  3. - using TUniTimer (client (browser) sends every x seconds a request for updates to the server)

     

    I think it's the best way

     

    - using "web sockets" (HTML5)

     

    It's too modern way

     

    - using "long polling" (see here)

    It's too complicated way.

     

    Suppose I use TUniTimer. Sorry for the following stupid questions, but there is no UniGui documentation and "all features demo" app didn't clear up the situation either.

    1) How to send a message (Delphi record) from a client to the server?

    I found a code sample:

    UniSession.SendResponse('New Text', False)

    Is it the way how the client sends a text message to the server?

    2) How should the server handle it?

    If found OnHTTPCommand event handler. Is that it?

    3) How to send a Delphi record from a client to the server?

    UniSession.SendStream?

    4)How should the server handle incoming stream?

    There is no OnStream event handler.

    5)How should the client retrieve new data from the server?

    I don't use databases. All data are in the server's memory.

     

    As I said I could not find a simple example which shows how to organize this client-server functionality properly.

  4. On the client side the events are triggered by interacting with controls.

    On the server side the events are triggered internally, without human intervention.

     

    In other words the clients display some server info and can modify some server parameters remotely.

    When the server parameter is changed (it could be also done due to other internal reasons) the server sends

    a message (delphi record) to all clients, they receive it and update the display info accordingly.

     

    Now this scheme works using TidTCPClient+TidTCPServer components bundle on the clients and the server (TidTCPClient

    sends a message, TidTCPServer handles received messages).

     

    I want to move from VCL to UniGui and use http for exchanging messages.

  5. Hello,

    I have two apps, a client VCL app and a server none-VCL app which work together exchanging data using TidTCPClient and TidTCPServer components on both sides. If one side wants to change the other it sends data in a way like this:

      with TidTCPClient.Create do
        try
          try
            Host := 'localhost';
            Port := 1234;
            ReadTimeout := 2000;
            Connect;
            with Socket do
            begin
              write(integer(1));
            end;
            Disconnect;
          except
          end;
        finally
          Free;
        end;
    
    

    It works simple and reliable. How to properly organize this two way communication using UniGui? Which components should I use?

     

×
×
  • Create New...