Delphi-Kylix
  Home arrow Delphi-Kylix arrow Page 2 - Server Code for an Internet Access Control...
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 
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

Server Code for an Internet Access Control Application
By: David Web
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-09-08

    Table of Contents:
  • Server Code for an Internet Access Control Application
  • Custom Procedures and Functions
  • Timing Procedure
  • Final Part of the Procedure

  • 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


    Server Code for an Internet Access Control Application - Custom Procedures and Functions


    (Page 2 of 4 )


    There are a few custom procedures and functions that I've created to facilitate the processing of communication and updating of the user interface. These are very important for the entire application and warrant a discussion. The first procedure is called "broadcastall" and is the medium that the program uses to communicate with all the workstations simultaneously:


    procedure TForm1.broadcastAll;


    var

    List: TList;

    Context: TMyContext;

    I: Integer;

    begin

    // List is inherited from TIdContext

    List := form1.ts.Contexts.LockList;

    try

    for I := 0 to List.Count-1 do

    begin

    Context := TMyContext(List[I]);

    try

    Context.Connection.IOHandler.WriteLn('shutdown:end@plchldr');


    except end;

    end;

    finally

    form1.ts.Contexts.UnlockList;

    end;

    end;


    The procedure defines a couple of variables, one of which is called Context. This variable inherits all of the properties of the TMyContext class and is extensively used throughout the procedure. The other variable that I want to draw your attention to is the "list" variable that is of type TList. This variable is used to inherit all the information that is contained in the TidContext class list:


    List := form1.ts.Contexts.LockList;


    The TidContext class contains a list of connected clients which is automatically generated and updated when a client connects or disconnects. The procedure starts by transferring the contents of the context object to the declared TList variable and locks the list, so that no new clients can be added while the procedure is busy broadcasting:

    List := form1.ts.Contexts.LockList;


    Then it counts the number of clients on the list and sets up a loop:


    try

    for I := 0 to List.Count-1 do

    begin

    Context := TMyContext(List[I]);


    The procedure then writes to each client on the list. The communication sends a command called shutdown as shown below:


    try

    Context.Connection.IOHandler.WriteLn('shutdown:end@plchldr');


    except end;

    end;


    and finally unlocks the list so it can be updated if needed:


    finally

    form1.ts.Contexts.UnlockList;

    end;

    end;


    More Delphi-Kylix Articles
    More By David Web


     

    DELPHI-KYLIX ARTICLES

    - Loading an XML Document into the DOM
    - 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...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek