Delphi-Kylix
  Home arrow Delphi-Kylix arrow Page 5 - Building an IRC Client
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 
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

Building an IRC Client
By: Leidago
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 7
    2007-01-22

    Table of Contents:
  • Building an IRC Client
  • Procedures
  • More Procedures
  • Sending Messages
  • Processing Server Commands

  • 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


    Building an IRC Client - Processing Server Commands


    (Page 5 of 5 )

    This event handler processes every single command that comes from the server.

    procedure TForm1.IdIRC1ServerListReceived(ASender: TIdContext;

      AServerList: TStrings);

     var

      i:integer;

    begin

    for i:= 0 to AServerList.Count-1 do begin

    memo1.lines.add(AServerList.Strings[i]);

    end;

    end;

    This event is fired when you receive a list of server names.

    procedure TForm1.IdIRC1ServerWelcome(ASender: TIdContext;

      AWelcomeInfo: TStrings);

    var

      i:integer;

    begin

    for i:= 0 to AWelcomeInfo.Count-1 do begin

    memo1.lines.add(AWelcomeInfo.Strings[i]);

    end;

    end;

    procedure TForm1.IdIRC1ServerVersion(ASender: TIdContext;
    Version, Host,

      Comments: String);

    begin

    memo1.Lines.Add(Version +'Host '+Host+'Comments '+Comments);

    end;

    procedure TForm1.Edit2Click(Sender: TObject);

    begin

    button1.Enabled:=true;

    end;

    procedure TForm1.Edit3Click(Sender: TObject);

    begin

    button1.Enabled:=true;

    end;

    procedure TForm1.IdIRC1MOTD(ASender: TIdContext; AMOTD:
    TStrings);

    var

      i:integer;

    begin

    for i:= 0 to AMOTD.Count-1 do begin

    memo1.lines.add(AMOTD.Strings[i]);

    end;

    end;

    procedure TForm1.IdIRC1UserInfoReceived(ASender: TIdContext;

      AUserInfo: TStrings);

    var

      i:integer;

    begin

    for i:= 0 to AUserInfo.Count-1 do begin

    memo1.lines.add(AUserInfo.Strings[i]);

    end;

    end;

    procedure TForm1.Button3Click(Sender: TObject);

    begin

     idIRC1.Join(edit3.text);

    //after joining you can request the names of the channels here,
    using the ListChannel() //function and then displaying the names
    in a memo.

    end;

    procedure TForm1.IdIRC1NicknamesListReceived(ASender: TIdContext;

      AChannel: String; ANicknameList: TStrings);

    var

      i:integer;

    begin

    memo1.Lines.Add('Nicknames in Channel: '+AChannel);

    for i:= 0 to ANicknameList.Count-1 do begin

    memo1.lines.add(ANicknameList.Strings[i]);

    end;

    end;

    This event fires when you receive a list of nicknames in a channel. The list itself is returned by the ListChannelNicknames() procedure. You also get other info such as the channel name.

    procedure TForm1.IdIRC1ServerUsersListReceived(ASender:
    TIdContext;

      AUsers: TStrings);

    var

      i:integer;

    begin

    for i:= 0 to AUsers.Count-1 do begin

    memo1.lines.add(AUsers.Strings[i]);

    end;

    end;

    procedure TForm1.IdIRC1NicknameError(ASender: TIdContext; AError:
    Integer);

    begin

    //here you get the error number(stored in AError above) and find
    the error that corresponds to the number.

    end;

    The last three procedures just make the GUI fun by setting the progress bar position whenever the client does any work.

    procedure TForm1.IdIRC1Work(ASender: TObject; AWorkMode:
    TWorkMode;

      AWorkCount: Integer);

    begin

     progb.Position:=AWorkCount;

    end;

    procedure TForm1.IdIRC1WorkBegin(ASender: TObject; AWorkMode:
    TWorkMode;

      AWorkCountMax: Integer);

    begin

    progb.Max:=AWorkCountMax;

    end;

    procedure TForm1.IdIRC1WorkEnd(ASender: TObject; AWorkMode:
    TWorkMode);

    begin

    progb.Position:=progb.Max;

    end;

    Below is a screen shot of the client in action:

    Conclusion

    I've shown you all the commands that this client application will implement. It is by no means all of the commands available, but it should give you the basis and inspiration to continue working through all the remaining commands.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Nothing that others will say will get listed :), nor is the onChannelMessage event...
       · I've not had a chance to test the app with the latest version of the Indy. When i...
     

    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...







    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek