Delphi-Kylix
  Home arrow Delphi-Kylix arrow Page 2 - Using the Command Handler Method in Delphi
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DELPHI-KYLIX

Using the Command Handler Method in Delphi
By: Leidago
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 2
    2006-12-18

    Table of Contents:
  • Using the Command Handler Method in Delphi
  • Implementing the Second and Third Commands
  • Setting the Greeting
  • Indy clients
  • Building a More Appealing Client

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Using the Command Handler Method in Delphi - Implementing the Second and Third Commands


    (Page 2 of 5 )

    Now, we need to implement the second command. So repeat what you did before except this time, add "Adate" to the command property. Then, to the Oncommand event, add the following code:

    procedure TForm1.IdCmdTCPServer1CommandHandlers1Command(

      ASender: TIdCommand);

    var

    AFormat: string;

    begin

    AFormat := 'yyyy-mm-dd hh:nn:ss';

    ASender.Context.Connection.IOHandler.WriteLn('Today''s date is:
    '+FormatDateTime(AFormat, Now));

    end;

    Again, this is a straightforward procedure that sends today's date to the requesting client. The AFormat variable formats the date so that it is displayed in the form of year-month-day hour:mins:secs.  The "Now" word in the line

    ASender.Context.Connection.IOHandler.WriteLn('Today''s date is:
    '+FormatDateTime(AFormat, Now));

    gets the current date and time.

    Repeat the process and let's implement the final command, which is to close down the connection. Add "quit" to the command property and to the Oncommand event add the following code:

    procedure TForm1.IdCmdTCPServer1CommandHandlers2Command(

      ASender: TIdCommand);

    begin

    ASender.Context.Connection.Disconnect;

    end;

    This procedure closes down the connection with this particular client. The other connected clients will still be connected. If you remember our previous discussions, you will recall that we used the term "context" a lot. This is because each client is dealt with, within its own context. Hence the "ASender.Context.Connection.Disconnect;".

    More Delphi-Kylix Articles
    More By Leidago


       · All comments are welcome, especially from those of you who write client server...
     

    DELPHI-KYLIX ARTICLES

    - Delphi Wrapper Classes and XML
    - Delphi and the DOM
    - Delphi and XML
    - Internet Access: Client Service
    - Finishing the Client for an Internet Access ...
    - The Client for an Internet Access Control Ap...
    - User Management for an Internet Access Contr...
    - Important Procedures for an Internet Access ...
    - Server Code for an Internet Access Control A...
    - Constructing the Interface for an Internet A...
    - Building a Server Application for an Interne...
    - Building an Internet Access Control Applicat...
    - Client Dataset: Working with Data Packets an...
    - Using the Client Dataset in an N-Tiered Appl...
    - Using the Client Dataset in Two-Tiered Clien...






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
    Stay green...Green IT