Newsgroups : Borland : borland.public.delphi.internet.winsock : 2008 Feb : Re: Indy 10 TIdIRC component problems.
| Subject: | Re: Indy 10 TIdIRC component problems. |
| Posted by: | "Unspoken" (ff_aa_cc_ee_..@wp.pl) |
| Date: | Fri, 8 Feb 2008 20:03:51 |
>> I've noticed that each time server sends something to my client,
>> TIdIRC automatycially responds with message "200".
>
> That appears to be a bug. TIdIRC should not be doing that, and did not do
> so in Indy 9. According to RFC 2812:
>
> "A numeric reply is not allowed to originate from a client."
If it tells you something, here is the code responsible for this (if i am
guessing correctly)
constructor TIdCommandHandler.Create(
ACollection: TIdCollection
);
begin
inherited Create(ACollection);
FReplyClass := TIdCommandHandlers(ACollection).ReplyClass;
if FReplyClass = nil then begin
FReplyClass := TIdReplyRFC;
end;
FCmdDelimiter := #32;
FEnabled := IdEnabledDefault;
FName := ClassName + Sys.IntToStr(ID);
FParamDelimiter := #32;
FParseParams := IdParseParamsDefault;
FResponse := TIdStringList.Create;
FDescription := TIdStringList.Create;
FNormalReply := FReplyClass.CreateWithReplyTexts(nil,
TIdCommandHandlers(ACollection).ReplyTexts);
if FNormalReply is TIdReplyRFC then begin
FNormalReply.Code := '200'; {do not localize}
end;
FHelpVisible := IdHelpVisibleDef;
// Dont initialize, pulls from CmdTCPServer for defaults
FExceptionReply := FReplyClass.CreateWithReplyTexts(nil,
TIdCommandHandlers(ACollection).ReplyTexts);
end;
I did as you said and it helped, thanks.
>
>> When I was using TIdTCPClient.IOHandler.Readln method I had
>> every messages from the server. When I am using TIdIrc.OnRaw
>> event, not every message from the server seems to get through.
>
> You should be getting everything. For every line that is read, an
> OnBeforeCommandHandler event is triggered internally, which calls the
> OnRaw event handler before the line is processed.
I know that I should but I don't ;-). I don't know why. I've tested it a
number of times and
the PING is not readed when I am using TIdIrc.OnRaw.
> TIdIRC responds to PING automatically, and then triggers its OnPingPong
> event to you afterwards.
Yeah I know that it should do this right here:
procedure TIdIRC.CommandPING(ASender: TIdCommand);
begin
Pong(ASender.Params[0]);
ShowMessage(ASender.Params[0]); //i've added this two weeks ago just to
tell me when it receives PING command
if Assigned(FOnPingPong) then
begin
OnPingPong(ASender.Context);
end;
end;
for two weeks of everyday usage I never get this command triggered.
But I will test more..and more..and more..;-)
However I am having other serious problem. My application hangs when I try
to imediately show a newly created channel tab in OnJoin event.
Maybe this has something to do with the internal TIdIrc thread? Here is an
example:
type
TForm13 = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
Edit1: TEdit;
Memo1: TMemo;
IdIRC1: TIdIRC;
procedure IdIRC1Raw(ASender: TIdContext; AIn: Boolean; AMessage:
string);
procedure FormActivate(Sender: TObject);
procedure Edit1KeyDown(Sender: TObject; var Key: Word; Shift:
TShiftState);
procedure IdIRC1Join(ASender: TIdContext; ANickname, AHost,
AChannel: string);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form13: TForm13;
procedure TForm13.Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key=VK_RETURN then
IdIRC1.Raw(Edit1.Text);
end;
procedure TForm13.FormActivate(Sender: TObject);
begin
IdIRC1.Connect;
end;
procedure TForm13.IdIRC1Join(ASender: TIdContext; ANickname, AHost,
AChannel: string);
var
tabSheet: TTabSheet;
memMemo: TMemo;
edEdit: TEdit;
begin
tabSheet := TTabSheet.Create(PageControl1);
with tabSheet do
begin
PageControl := PageControl1;
Parent := PageControl1;
end;
edEdit := TEdit.Create(Self);
with edEdit do
begin
Parent := tabSheet;
Align := alBottom;
end;
memMemo := TMemo.Create(Self);
with memMemo do
begin
Parent := tabSheet;
Align := alClient
end;
PageControl1.ActivePage := tabSheet; // BIG freeze here
end;
procedure TForm13.IdIRC1Raw(ASender: TIdContext; AIn: Boolean;
AMessage: string);
begin
Memo1.Lines.Add(AMessage);
end;
I don't know how to solve this. I've noticed that if i set ActivePage after
some time since its creation (like 1 second) than everything is working
fine. How should i synchronize this?
Here is the fully working example with bug included ;-)
http://www.speedyshare.com/736403688.html