delphi - Error with PrivateMessages in IdIRC -
hi have problem following code:
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') begin // end; irc.free; end; except on e: exception writeln(e.classname, ': ', e.message); end; end.
the problem when receive private message, anickname entry gives me following error:
project test.exe raised exeption class #c00000005 message 'access violation @ 0x00404673:read of adress 0x03cf4e58
what doing wrong?
tidircprivmessageevent
"procedures of object", implicitly references object. added self
parameter that, omitted tidcontext
parameter part of event:
procedure ircprivatemessage(aself: pointer; sender: tidcontext; const anickname, ahost, atarget, amessage: string); begin .... end;
Comments
Post a Comment