Home arrow Delphi-Kylix arrow Server Side Chat Application with Borland Delphi/Indy, concluded
DELPHI-KYLIX

Server Side Chat Application with Borland Delphi/Indy, concluded


This article picks up where last week's article on building a server side chat application left off. By the time you reach the end, you should have a fully functioning chat server.

Author Info:
By: Jacques Noah
Rating: 4 stars4 stars4 stars4 stars4 stars / 11
January 02, 2006
TABLE OF CONTENTS:
  1. · Server Side Chat Application with Borland Delphi/Indy, concluded
  2. · Code for connecting clients
  3. · The heart of the application
  4. · Code for leaving a chat

print this article
SEARCH DEVARTICLES

Server Side Chat Application with Borland Delphi/Indy, concluded
(Page 1 of 4 )


A downloadable zip of the COMPLETE source code for the application is available

here.

Introduction

In this part we are going to finish off the server side coding of our Chat Application. In the previous part - Server Side Chat Application with Borland Delphi/Indy - we discussed how the server actually carries out all its communication functions as well as how it interacts with the client application. We also defined and implemented all of the procedures and commands needed to run our custom communication protocol.

Let’s continue…

I’m not going to go in detail about how the code works, however, I will make sure to comment the code heavily, so that it makes sense when you read it.

Add the following three procedures in the implementation section:

procedure TLog.DoSynchronize;
    begin
     form1.Memo1.Lines.Add(FMsg);
   
    end;
    class procedure TLog.AddMsg(const AMsg: String);
    begin
        with Create(AMsg) do try
            Synchronize;
        finally
            Free;
        end;
    end;
   constructor TForm1.Create(AOwner: TComponent);
    begin
        inherited Create(AOwner);
        ts.ContextClass := TMyContext;
    end;

As I said in the previous tutorial, this code basically helps to keep the server working flawlessly by synchronizing messages that need to be displayed by components on the server form.

Next, double click on the connect button and add the following code:

procedure TForm1.btconnectClick(Sender: TObject);
begin
ts.DefaultPort:=strtoint(edport.Text);
ts.Active:=true;
memo1.Lines.Add('Server is now connected and ready to accept clients');
end;

This code just gets the server  to listen on the said port number as well as display a message.


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