Home arrow Delphi-Kylix arrow Page 3 - 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 - Disconnecting from the Server
(Page 3 of 5 )

If the name was not sent, the socket is disconnected, because without the name a workstation cannot be identified and listed on the server user interface. 

begin

Connection.IOHandler.WriteLn('Workstation name not provided! Goodbye.');

Connection.Disconnect;

end;

end;

end;


When a client or workstation is disconnecting from the server, several things need to happen. First, the server must disconnect the client, and second, it must update the server applications user interface. The tsDisconnect() procedure does exactly that:


procedure TForm1.tsDisconnect(AContext: TIdContext);

var

aname:string;

li:tlistitem;

begin

TLog.AddMsg(TMyContext(AContext).compname + ' is disconnected');

aname:=TMyContext(AContext).compname;

//find computer name on the list view and remove it

li:=lv.findcaption(0,aname,true,true,true);

if li <> nil then

begin

li.Selected:=true;

li.Delete;

end;

end;


The first line of the procedure updates the memo component of the server using TLog’s AddMessage procedure. As you may recall, this procedure is created specifically to update the memo component to prevent the main thread from trying to update the component itself. So, if a client disconnects, you will see a visual confirmation of this both on the memo and on the list view components:


TLog.AddMsg(TMyContext(AContext).compname + ' is disconnected');


The second line stores the name of the disconnecting client in a string variable called “aname”:


aname:=TMyContext(AContext).compname;


Then it uses the list views findcaption() function to search for the name of the client on the list. This is because we want to remove the name of the disconnecting client from the visually:


li:=lv.findcaption(0,aname,true,true,true);


The findcaption() function returns either a nil value or a value greater than nil. If the value is not nil, then it means that the name has been found on the list and it will then remove the name using the delete() property of the list view component:


if li <> nil then

begin

li.Selected:=true;

li.Delete;

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