Home arrow Delphi-Kylix arrow Page 4 - Important Procedures for an Internet Access Control Application
DELPHI-KYLIX

Important Procedures for an Internet Access Control Application


In the preceding article we started to explore the code that makes up the server communication. If you haven’t read that article, please make sure to do so, because almost everything that I will be discussing in this article will directly reference code that we discussed there. A lot of the things that we will be discussing here will make sense once you have read the previous article.

Author Info:
By: David Web
Rating: 5 stars5 stars5 stars5 stars5 stars / 7
September 15, 2008
TABLE OF CONTENTS:
  1. · Important Procedures for an Internet Access Control Application
  2. · Taking Names
  3. · Disconnecting from the Server
  4. · The tsExecute Procedure
  5. · Suggested Improvements

print this article
SEARCH DEVARTICLES

Important Procedures for an Internet Access Control Application - The tsExecute Procedure
(Page 4 of 5 )

 

The tsExecute procedure deals with any commands or request that a client sends over; so far in this implementation it only deals with the ‘timesup’ command. This command tells the server that the client has finished with the Internet session and that it is ready for another session to be allocated:


procedure TForm1.tsExecute(AContext: TIdContext);

var

str,spacer,thename,cmd:string;

li:tlistitem;

begin

str:=acontext.Connection.IOHandler.ReadLn;

ParseString(str,cmd,thename,spacer);

if cmd = 'timesup' then begin

//search for workstation name in treeview and set its status to 'free'

li:=lv.FindCaption(0,thename,true,true,true);

if li <> nil then begin

li.Selected:=true;

li.ImageIndex:=0;

li.SubItems.Strings[0]:='-';

li.SubItems.Strings[1]:='-';

li.SubItems.Strings[2]:='-';

li.SubItems.Strings[3]:='-';

li.SubItems.Strings[4]:='free';

end;

end;

end;


First the procedure reads the communication from the client into a string variable called “str”:


str:=acontext.Connection.IOHandler.ReadLn;


Then the string is parsed into three separate parts: the command, the name of the sender and a placeholder:


ParseString(str,cmd,thename,spacer);


Next the procedure checks to see what command has been sent. If the command is “timesup,” it continues to search for the name of the computer in the list of names in the list view, and then sets the status of that computer to “free.”


//search for workstation name in treeview and set its status to 'free'

li:=lv.FindCaption(0,thename,true,true,true);

if li <> nil then begin

li.Selected:=true;

li.ImageIndex:=0;

li.SubItems.Strings[0]:='-';

li.SubItems.Strings[1]:='-';

li.SubItems.Strings[2]:='-';

li.SubItems.Strings[3]:='-';

li.SubItems.Strings[4]:='free';


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