Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Problema con evento PrivateMessages en IdIRC (https://www.clubdelphi.com/foros/showthread.php?t=87202)

JuanOrtega 27-11-2014 19:29:44

Problema con evento PrivateMessages en IdIRC
 
Hola tengo un problema con el siguiente codigo :

Código:

program test;

{$APPTYPE CONSOLE}
{$R *.res}

uses
  System.SysUtils, idIRC, idContext, idGlobal;


// procedure TForm1.IdIRC1PrivateMessage(ASender: TIdContext; const ANickname,
// AHost, ATarget, AMessage: string);

// procedure TForm1.IdIRC1Raw(ASender: TIdContext; AIn: Boolean;
// const AMessage: string);

procedure IrcPrivateMessage(ASelf: Pointer; const ANickname, AHost, ATarget,
  AMessage: string);
begin
  Writeln('[+] Message ' + ANickname + ' > ' + AMessage);
end;

procedure IrcRaw(ASelf: Pointer; ASender: TIdContext; AIn: Boolean;
  const AMessage: String);
begin
  Writeln(iif(AIn, '[Recv] ', '[Sent] ') + AMessage);
end;

var
  irc: TIdIRC;
  m1: TMethod;
  m2: TMethod;

begin
  try
    irc := TIdIRC.Create(nil);
    try
      irc.Host := 'localhost';
      irc.Port := 6667;
      irc.Nickname := 'tester';
      irc.Username := 'tester';

      m1.Code := @IrcRaw;
      m1.Data := irc;
      irc.OnRaw := TIdIRCRawEvent(m1);

      m2.Code := @IrcPrivateMessage;
      m2.Data := irc;
      irc.OnPrivateMessage := TIdIRCPrivMessageEvent(m2);

      try
        irc.Connect;
      except
        Writeln('Nay');
        Exit;
      end;

      Writeln('Yeah');

      irc.Join('#locos');

      while ('1' = '1') do
      begin
        //
      end;

    finally
      irc.Free;
    end;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;

end.

Cita:

Project test.exe raised exeption class #C00000005 with message 'access violation at 0x00404673:read of adress 0x03cf4e58
Estoy usando el componente IdIRC con Delphi XE2 y al parecer solo pasa con el ANickname , ¿ como se soluciona ese error ?


La franja horaria es GMT +2. Ahora son las 18:10:40.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi