Delphi-Kylix
  Home arrow Delphi-Kylix arrow Page 3 - 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 - Receiving messages: listnames, all, takeshot, name, file


    (Page 3 of 5 )

    When a client sends a message it will be received (by the server) in this form: from@msg:to

    from: represents the name of the client who sends the message
    msg: represents the actual message or command
    to: represents the name of the sender

    When the server receives this message it will need to break it down into three parts to make sense of it. Put this function anywhere in the implementation section. 

    The following code makes this possible:

    function ParseString(s : string; var str1,str2,str3: string) :
    boolean;
    var
       P1,P2 : integer;
    begin
       P1 := Pos('@',s);
       P2 := Pos(';',s);
       //Test if both delimiters are present, in the right order and
       //at least 1 char apart
       if ((P1 > 0) and (P2 > 0) and (P2 > P1) and (Abs(P2-P1) > 1))
         then begin
                str1 := Copy(s,1,P1-1);
                str2 := Copy(s,P1+1,P2-P1-1);
                str3 := Copy(s,P2+1,Length(s)-P2);
                Result := True; //valid string
              end
         else Result := False; //invalid string
    end;

    All that this function does is take in a string - s : string – and break it down into three parts, based on two delimiters which are - @ AND : - So, if I send a message saying ‘hello mate’, the server will receive: fromme@hello mate:toyou. The parsestring function will take that message and break it down into sender, message, recipient. 

    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 4 hosted by Hostway
    Stay green...Green IT