Home arrow Delphi-Kylix arrow Page 4 - Constructing the Interface for an Internet Access Control Application
DELPHI-KYLIX

Constructing the Interface for an Internet Access Control Application


In this third part to a six-part article that shows how to build an application for Internet access control, such as you might find in an Internet cafe, we will mainly be dealing with the functionality of the main server application. This is the application that will provide us with both the interface and capability to manage client sessions.

Author Info:
By: David Web
Rating: 5 stars5 stars5 stars5 stars5 stars / 2
September 02, 2008
TABLE OF CONTENTS:
  1. · Constructing the Interface for an Internet Access Control Application
  2. · The Main Server Application
  3. · Code continued
  4. · Still More Code
  5. · Code Concluded

print this article
SEARCH DEVARTICLES

Constructing the Interface for an Internet Access Control Application - Still More Code
(Page 4 of 5 )


procedure TForm1.Exit1Click(Sender: TObject);

begin

if ts.Active = true then ts.Active:=false;

application.Terminate;

end;


procedure TForm1.Settings1Click(Sender: TObject);

begin

form4.show;

end;


procedure TForm1.LogOff1Click(Sender: TObject);

begin

form1.level:='';

form1.Caption:='';

form1.Close;

form3.isLogon:=false;

form3.Visible:=true;

end;


procedure TForm1.tsConnect(AContext: TIdContext);

var

str,cmdrslt,cmd,placeholder:string;

begin

with TMyContext(AContext) do

begin

Con := Now;

if (Connection.Socket <> nil) then

IP :=Connection.Socket.Binding.PeerIP;

//state:='Free';

//compname:= GStack.HostByAddress(IP);

str:=Connection.IOHandler.ReadLn;

//GetComputername+':free@plchldr'

parsestring(str,cmdrslt,cmd,placeholder);

compname:=cmdrslt;

if compname <> '' then

begin

li:=lv.Items.Add;

li.ImageIndex:=0;

li.Caption:=cmdrslt;

li.SubItems.Add('-');

li.SubItems.Add('-');

li.SubItems.Add('-');

li.SubItems.Add('-');

li.SubItems.Add(cmd);

end else

begin

Connection.IOHandler.WriteLn('No Nick provided! Goodbye.');

Connection.Disconnect;

end;

end;

end;


procedure TForm1.tsDisconnect(AContext: TIdContext);

var

aname:string;

li:tlistitem;

begin

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

aname:=TMyContext(AContext).compname;

//get compname

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

if li <> nil then

begin

li.Selected:=true;

li.Delete;

end;

end;


procedure TForm1.BitBtn2Click(Sender: TObject);

begin

ts.DefaultPort:=1150;

ts.Active:=true;

memo1.Lines.Add('Server Active' + #13#10 +'and ready to accept clients');

end;


procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);

begin

//application.Terminate;

end;


procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);

begin

form3.uname.Clear;

form3.upass.Clear;

form3.Visible:=true;

end;




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;

{ Broadcast Message to every connected workstation

else if cmd='all' then begin

//'all'+'@'+mname.text+'&'+edto.text+'|'+msgs.lines.Text);

ParseString(str,cmd,fromname,toname,themsg);

// showmessage('the entire string= ' + str + ' The Cmd= ' + cmd + ' From: ' + fromname + ' To: ' + toname + ' The Msg: ' + themsg );

tmycontext(acontext).broadcastMsgAll(fromname, themsg);}

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