Home arrow Delphi-Kylix arrow Page 2 - Server Code for an Internet Access Control Application
DELPHI-KYLIX

Server Code for an Internet Access Control Application


In the preceding article we dealt with the functional requirements of the server application as well as with the components that make up the server interface. In this article we will continue to build on the concepts that we discussed there and at the same time explore the code that runs the server application.

Author Info:
By: David Web
Rating: 5 stars5 stars5 stars5 stars5 stars / 9
September 08, 2008
TABLE OF CONTENTS:
  1. · Server Code for an Internet Access Control Application
  2. · Custom Procedures and Functions
  3. · Timing Procedure
  4. · Final Part of the Procedure

print this article
SEARCH DEVARTICLES

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;



blog comments powered by Disqus
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...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials