Jump to content

pcplayer99

Members
  • Content Count

    93
  • Joined

  • Last visited

Posts posted by pcplayer99


  1. Thanks FredS, 

    after I add "With Self do"  in my helper class, it can access provate field in another unit.

     

     

    in unit1, here is TMyClassB:

     

    TMyClassB = class
      private
        FMyClassA: TMyClassA;
        function GetMyName: string;
      public
        constructor Create;

        property MyName: string read GetMyName;
      end;

     

     

    in Unit2, here is my helper class:

    TMyClassB3 = class helper for TMyClassB
      public
        constructor Create(B: Boolean); overload;
      end;

     

    constructor TMyClassB3.Create(B: Boolean);
    begin
      //if B then FMyClassA := TMyClassA2.Create;  //helper class can not access private field.

     

      //use with self do, here can access private field
      with Self do
      begin
        FMyClassA := TMyClassA2.Create;
      end;
    end;

     

     


  2. 10 hours ago, FredS said:

    How to call a private method of a class inside a Berlin+ class via Helper

    
    procedure TSomeClassHelper.CheckAccessToPrivate;
    begin
     With Self do begin // access via with works
       FInt :=1;
       SomeMethod;
     end;
    end;
    
    // Declared in another unit as:
    type TSomeClass = class
        private
          FInt : integer;
          procedure SomeMethod;
      end;

     

     

    Thank you Fred. I will try helper class mode.


  3. 20 hours ago, FPiette said:

    Not sure I correctly understand what need and what you've done. I understood that you copied Delphi source code in another unit and then modified that unit to fit you needs. Then why not modify it further to make visible what you need ?

     

    btw: Modifying a Delphi unit although technically correct, will make your application difficult to maintain on the long term as Delphi source code will change: you'll have to apply your changes, if possible, to the new source and this may be difficult or even impossible. To avoid this problem, you probably have to change your design.

     

     

     

    Yes, this is why I do not want to copy it and modify it, I just want to inherit a new class in a new unit, to avoid modify Delphi's source file.


  4. In unit Soap.SOAPLinked.pas there are:

     

    1. TLinkedWebNode

    2. TLogLinkedWebNode = class(TLinkedWebNode)

    3. TLinkedRIO = class(TRIO)

     

    in TLinkedRIO, it has two constructor: 

    one is for: FLinkedWebNode := TLinkedWebNode.Create(nil); 

    and another is for: FLinkedWebNode := TLogLinkedWebNode.Create(nil);

     

    My question is:

    if I want to create a new TLinkedWebNode like TLogLinkedWebNode, Just named it TMyWebNode, I must let TLinkedRIO has a new constructor that lets it create FLinkedWebNode  as my new TMyWebNode.

     

    but, I can not modify Soap.SOAPLinked.pas because it is source code in Delphi. I will create a new pas file and inherit TLinkedRIO like TMyRIO = class(TLinkedRIO) and add a new constructor in it.

     

    but, the new TMyRIO in a new pas unit, I can not access FLinkedWebNode like FLinkedWebNode := TMyWebNode.Create(nil); 

     

    So, is there any way to do that? or this is a design issue in Soap.SOAPLinked.pas and I must modify it?

     

     


  5. I have made a drone controller APP years ago. It was made by Firemonkey, through WiFi to communication with a WiFi camera, play real time video stream from camera on the drone, and send control command to camera and the camera forward this command to drone controller through UART.


  6. [Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D.]

     

    According to the above statement, it just supports draw the image to the screen, there is no decoder in it.

     

    To using DirectShow, there is H.264 decoder you can use. There is an open-source decoder for DirectShow named FFDShow.


  7. [SDL is written in C, works natively with C++, and there are bindings available for several other languages, including C# and Python.]

     

    So, I do not know if it is can be used in Delphi.

     

    I have updated Dspack to let it can compile in higher version Delphi, so, it is still can be used in the new version of Delphi.

     

    Here is my updated version: https://github.com/pcplayer/Dspack

     

    In Windows, DirectShow still exists, and if you using Delphi to play media, you still can using DirectShow. And Dspack is a set of open-source  Delphi code for DirectShow. 


  8. Hi,

     

    These codes I have tested ok.

     

    Server Side:

    unit TestAttachImpl;
     
    interface
     
    uses Soap.InvokeRegistry, System.Types, System.SysUtils, Soap.XSBuiltIns, TestAttachIntf;
     
    type
     
      { TTestAttach }
      TTestAttach = class(TInvokableClass, ITestAttach)
      public
        procedure GetAttach(var FileName: string; out Attach: TSOAPAttachment); stdcall;
        procedure PutAttach(const FileName: string; Attach: TSOAPAttachment); stdcall;
      end;
     
    implementation
     
     
    { TTestAttach }
     
    procedure TTestAttach.GetAttach(var FileName: string; out Attach: TSOAPAttachment);
    var
      Fn: string;
    begin
      //Send file to client
      Fn := 'F:\H264Output.mp4';
     
      Attach := TSOAPAttachment.Create;
      Attach.SetSourceFile(Fn);
      FileName := ExtractFileName(Fn);
    end;
     
    procedure TTestAttach.PutAttach(const FileName: string;
      Attach: TSOAPAttachment);
    begin
      //receive file that client upload
      Attach.SaveToFile(ExtractFilePath(GetModuleName(0)) + FileName);
    end;
     
    initialization
    { Invokable classes must be registered }
       InvRegistry.RegisterInvokableClass(TTestAttach);
    end.

     

     

    Client-side:

    
    procedure TForm2.Button1Click(Sender: TObject);
    var
      Attach: TSOAPAttachment;
      Intf: ITestAttach;
      Path, Fn: string;
    begin
      //client download file
      Path := ExtractFilePath(Application.ExeName);
      Attach := TSOAPAttachment.Create;
      Intf := HTTPRIO1 as ITestAttach;
      try
        Intf.GetAttach(Fn, Attach);
        Attach.SaveToFile(Path + Fn);
      finally
        Intf := nil;
        Attach.Free;
      end;
     
    end;
     
    procedure TForm2.Button2Click(Sender: TObject);
    var
      Fn: string;
      Attach: TSOAPAttachment;
      Intf: ITestAttach;
    begin
      //client upload file
      if OpenDialog1.Execute then
      begin
        Fn := OpenDialog1.FileName;
     
        Attach := TSOAPAttachment.Create;
        Attach.SetSourceFile(Fn);
        Intf := HTTPRIO1 as ITestAttach;
        try
          Intf.PutAttach(ExtractFileName(Fn), Attach);
        finally
          Intf := nil;
          Attach.Free;
        end;
      end;
    end;

     


  9. Hi,

     

    OK, you can not setup router. Then you must have a server on the Internet that your LAN APP and your Android APP can get connected. This is not about callbacks or other tech. This is about how tow to establish  communication between two device.

     

    Under normal conditions, to establish connection between two device, there must be a server, both device connect to this server, this server is working as a bridge.

    • Like 1

  10. Your issue is:

     

    A server working in a LAN server which has a private IP address, and your client want to access from Internet.

     

    If your LAN has a Internet router, and if you can setup the port mapping of this router, then your client can access your server from Internet.

     

    This is a simple diagram of port mapping:

     

    Internet -- xx.xx.xx.xx(Your router's public IP address) --- (port 8888: 192.168.1.20:9999 -- this is the port mapping setup in your router) --- Your Server on 192.168.1.20:9999.

     

    If your router's public IP address is dynamic, you will using some dynamic DNS services to let a fixed DNS name point to your dynamic IP address.


  11. On 3/10/2020 at 8:36 PM, pieomy00 said:

     

    Hi,

    what is the best way LoadFromFile & Thread? (FMX ios and android)

     

    I'm using this code but i dont know this is good or bad

    also there is any usage limit for this? (same time with different bitmaplistanimation components)

     

    my main goal is make sprite sheet animation based game, I have a lot of sprite animation and I need load and unload on runtime.

    thank you.

     

     

    
    TThread.CreateAnonymousThread(procedure ()
      begin
        try
          BitmapListAnimation1.AnimationBitmap.LoadFromFile(MyFile);
        finally
        end;
        
        TThread.Synchronize (TThread.CurrentThread,
          procedure ()
          begin
            BitmapListAnimation1.Enabled:=true;
          end);
      end).Start;

     

     

    You said that [there is any usage limit], what is your mean?

     

    LoadFromFile need some time because your file is very large, even if you put it into a thread, it still need the same duration.

     

    Maybe you need put it into a thread, and run this thread at a right time such as before you want show these pictures. Such as, your game is nearly to the end of scense, but there are some seconds needed, then you start load file thread, and your user is still playing game, and when the game go end, your load file operation is complete.

     

    If you must free the resource of previous scense and then you have enough memory space to load the files the second scense need, then you need to show a transitions to user and then load file in a thread. 

     


  12. I have some experience that using Indy TCP client to remote control some device through WiFi.

     

    My experience is that when the distance between mobile and device is out of range, you can test the connection by send some data and wait it timeout and in except section to close connection, like this:

     

    try

      IdTCPClient1.Send(....);

    except

      IdTCPClient1.Disconnect;

    end;

     

    and then try re-connect again, and again, and when mobile is into the range of device WiFi, you can connect again.


  13. I have used Indy FTP server. You can start from Indy's demo code.

     

    How about ICS? I have never used ICS.

     

    On IIS server, you must close its own FTP server because it using port 21, and your own FTP server such as Indy TFP server will use it.

    Or, your own FTP server can setup to using other port, and you will tell your user to ftp another port such as: FTP://your-server-IP:2121


  14. Hi,

     

    I do not know MVVM, MVC etc.

     

    My experience is you should using interface in your code. And you should not using implement them with abstract classes.

     

    Abstract classes is not for interface. If you have another reason to using abstract classes you just use it but not for interface.

     

    For example, the framework of Delphi WebService is based on interface, and Delphi DataSnap framework is based on class. I like WebService framework but DataSnap framework.

×