Morphumax 0 Posted March 1 (edited) Hello I am new to Delphi and I am trying to use the NetCom7 library in order to upgrade an existing Client-Server application from Delphi 7 to Delphi 11. The existing code uses Indy10. Currently, I am simply trying to make the NetCom7 ChatDemo work. I am using the instructions below taken from https://github.com/DelphiBuilder/NetCom7. Quote Server: - You put a TncServerSource on your form. If you want you can change the port it is listening to via the Port property. - You implement an OnHandleCommand event handler and, depending on aCmd parameter (integer), you respond the result of the command via setting the Result of the OnHandleCommand to anything you like (TBytes). If an exception is raised while in HandleCommand, it is trapped, packed, transfered accross to the calling peer, and raised at the peer's issued ExecCommand. This way exceptions can be handled as if they were raised locally. - You set the Active property to true. Your server is ready. Client: - You put a TncClientSource on your form. You can set Host and Port to whatever you want. - You set Active property to true. Your client is now connected to the server. - You call ExecCommand (on your TncClientSource), with any command number and data that you like. This will send your command and data over to the server, call its OnHandleCommand, pack the response, and return it as a result to your ExecCommand. - ExecCommand is blocking (if aRequiresResult parameter is set to true), but only for the current command issued. The TncClientSource's OnHandleCommand still executes, so, while waiting for a command to return, your client socket may be processing requests from your server (a server can also ExecCommand to a client). - If you have forgotten to set Active to true and call ExecCommand, the TncClientSource will first try to connect, so you can ommit setting this property. It will also try to connect if it knows it has been disconnected (and the Reconnect property is set to true). I have added a TncServerSource to the Server form and I have added a TncClientSource to the Client form. I am trying to implement an OnHandleCommand event handler now. Below is some of my Server code. procedure HandleCommand(Sender: TObject; aLine: TncLine; aCmd: Integer; aData: TGUIDHelper.Create(System.TArray<System.Byte>, System.Types.TEndian).:1<Byte>, aRequiresResult: Boolean; aSenderComponent: string; aReceiverComponent: string); procedure TfrmMain.btnActivateServerClick(Sender: TObject); begin try Server.OnHandleCommand := HandleCommand(); Server.Active := not Server.Active; I am currently getting an error on line 1 saying Unsatisfied forward or external declaration. Any help/examples would be appreciated. Thanks M Edited March 1 by Morphumax Share this post Link to post
Lajos Juhász 295 Posted March 1 HandleCommand is an event handler, it should be a method of an object, not a procedure. You should add it to your TfrmMainClass. Share this post Link to post
Cristian Peța 107 Posted March 1 20 minutes ago, Morphumax said: procedure HandleCommand(Sender: TObject; aLine: TncLine; aCmd: Integer; aData: TGUIDHelper.Create(System.TArray<System.Byte>, System.Types.TEndian).:1<Byte>, aRequiresResult: Boolean; aSenderComponent: string; aReceiverComponent: string); aData type is terrible... is this Delphi code? Share this post Link to post
Morphumax 0 Posted March 1 12 minutes ago, Lajos Juhász said: HandleCommand is an event handler, it should be a method of an object, not a procedure. You should add it to your TfrmMainClass. Does Delphi not just use procedures and functions? 5 minutes ago, Cristian Peța said: aData type is terrible... is this Delphi code? Delphi. I just tried to copy the parameters specified in the hint box. There were quite a few. Share this post Link to post
Cristian Peța 107 Posted March 1 4 minutes ago, Morphumax said: Delphi. I just tried to copy the parameters specified in the hint box. There were quite a few. Maybe I am from ice age and Delphi evolved since then... but this does not compile in D11.3: E2005 'Create' is not a type identifier Calling TGUIDHelper.Create() in procedure declaration where you need to give a type is somehow strange for me. Share this post Link to post
Lajos Juhász 295 Posted March 1 18 minutes ago, Morphumax said: Does Delphi not just use procedures and functions? No, that was Turbo Pascal before OOP was introduced. https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Classes_and_Objects_(Delphi) Share this post Link to post
Morphumax 0 Posted March 1 6 minutes ago, Cristian Peța said: Maybe I am from ice age and Delphi evolved since then... but this does not compile in D11.3: E2005 'Create' is not a type identifier Calling TGUIDHelper.Create() in procedure declaration where you need to give a type is somehow strange for me. Yeah, I think I need to use the return value type of Create. Share this post Link to post
Lajos Juhász 295 Posted March 1 Just now, Morphumax said: Maybe I am from ice age and Delphi evolved since then... but this does not compile in D11.3: E2005 'Create' is not a type identifier Calling TGUIDHelper.Create() in procedure declaration where you need to give a type is somehow strange for me. Try to add the event handler using the object inspector. Delphi will generate the correct code. Select Server on the form then in Object inspector go to Events and double click on combobox for the OnHandleCommand event. (That is a more traditional way assign events.) Share this post Link to post
Morphumax 0 Posted March 1 Thanks for your help. I think I'm going to try Internet Component Suite now as it seems to be more widely used. M Share this post Link to post