Delphi-Kylix
  Home arrow Delphi-Kylix arrow Page 2 - Sever Side Chat Application with Borland D...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DELPHI-KYLIX

Sever Side Chat Application with Borland Delphi/Indy
By: Jacques Noah
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 12
    2005-12-26

    Table of Contents:
  • Sever Side Chat Application with Borland Delphi/Indy
  • The Code
  • Receiving messages: listnames, all, takeshot, name, file
  • Handling Commands: Listnames, all, takeshot
  • Handling commands: name, file

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Sever Side Chat Application with Borland Delphi/Indy - The Code


    (Page 2 of 5 )

    The first thing we need to do is create a class that will take the details  of every client that connects to the chat. For now we will only take three, the IP address(which will enable you to ban a client if necessary), Nick name and time/date of connection. We also define procedures to send messages, list connected names and files in the same class. Place the following code just below the ‘type’ heading of the form, making sure that it is above the form declaration.

     

    TMyContext = class(TIdContext)
            public
                IP: String;
                Nick: String;
                Con: TDateTime;
               // compname:string;
                procedure SendMsg(const ANick: String; const AMsg:
    String);
                procedure BroadcastMsg(const bmsg: String);
               procedure BroadcastMsgAll(const ANick: String; const
    bmsg: String);
                 procedure SendNicks;
               procedure SendFile(const ANick,Fn:string);
            end;

    The code below is responsible for displaying messages. It frees up the main VCL thread. Without it, I found that the server system usually crashes.

     TLog = class(TIdSync)
            protected
                FMsg: String;
                procedure DoSynchronize; override;
            public
                constructor Create(const AMsg: String);
                class procedure AddMsg(const AMsg: String);
            end;

    Add this line of code above the private section of the form:

    constructor Create(AOwner: TComponent);override;

    Also, add this under the ‘var’ section of the form:

     names:string;

    and add in the implementation section:

    uses jpeg;

    Our communication protocol commands

    listnames = request list of names of connected clients
    all            = send message to all connected clients
    takeshot  = takes a screenshot of any client
    name       = sends a private message to named client
    file          = sends a file

    More Delphi-Kylix Articles
    More By Jacques Noah


       · We hope you found this article enjoyable and educational. Please feel free to...
       · This has been really informative, and helped me redesign a freeware game servrer I...
       · For all those who sent me emails requesting to download the chat application. I've...
       · I downloaded the file and ran it under D7 and using Indy10.1.5[Error]...
     

    DELPHI-KYLIX ARTICLES

    - 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...
    - Using the Client Dataset in Two-Tiered Clien...






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
    Stay green...Green IT